Back to Library
Utility Nov 22, 2025

Checkpoint System

T
by terrorsoul

When a player enters the checkpoint area itll set the spawn point for them to that checkpoint

LUA
-- Configuration: Set coordinates for the checkpoint
local checkpointPosition = tm.vector3.Create(0, 300, 100)
local checkpointTrigger = nil

function SetupCheckpoint()
    -- Spawn a 15x15x15 trigger box at the position
    checkpointTrigger = tm.physics.SpawnBoxTrigger(checkpointPosition, tm.vector3.Create(15, 15, 15))
    
    -- Register the callback function. 
    -- The game will automatically pass the 'playerId' of the person entering the zone.
    tm.physics.RegisterFunctionToCollisionEnterCallback(checkpointTrigger, "OnPlayerEnterCheckpoint")
end

function OnPlayerEnterCheckpoint(playerId)
    -- 1. Define the spawn coordinates for the ID "Checkpoint_1"
    -- We use the checkpointPosition so they respawn exactly where the trigger is
    tm.players.SetSpawnPoint(playerId, "Checkpoint_1", checkpointPosition, tm.vector3.Create(0, 0, 0))
    
    -- 2. Set "Checkpoint_1" as the active spawn location for this player
    tm.players.SetPlayerSpawnLocation(playerId, "Checkpoint_1")
    
    -- 3. Show a message only to the player who entered
    tm.playerUI.ShowIntrusiveMessageForPlayer(playerId, "CHECKPOINT", "Progress Saved!", 2)
end

-- Initialize the checkpoint
SetupCheckpoint()

Discussion

Please log in to post a comment.