Place checkpoint Parts that remember a player's position, then spawn them back there instead of at the start.
The health-damage lesson respawns back at the default spawn. This lesson upgrades that: place checkpoints around the map, remember where each last passed one, and respawn them there so a fall doesn't mean restarting the whole level.
Keep a that maps (or their userId) to the position of their latest checkpoint:
local Players = game:GetService("Players")
local checkpoints = {} -- [player.UserId] = CFrame (from — profile)
local function setCheckpoint(player, cframe)
checkpoints[player.UserId] = cframe
end
local function getCheckpoint(player)
return checkpoints[player.UserId]
end
Keying by UserId (not the object) means the data survives name changes and is easy to look up. If the has no entry yet, that's their signal they haven't reached any checkpoint — respawn them at the start.
UserId is the 's permanent, unique account number. It stays the same forever, even if they change their display name.
The unique, permanent number that identifies a player's account is their
A checkpoint in the fires Touched when a character walks into it:
local function onCheckpointTouched(checkpoint, hit)
local character = hit.Parent
local localPlayer = Players:GetPlayerFromCharacter(character)
if not localPlayer then return end
local checkpointPart = checkpoint.PrimaryPart or checkpoint
setCheckpoint(localPlayer, checkpointPart.CFrame)
end
-- Attach to a checkpoint model
local checkpoint = workspace:WaitForChild("Checkpoint1")
checkpoint.Touched:Connect(function(hit)
onCheckpointTouched(checkpoint, hit)
end)
The important detail: a checkpoint is often a Model (a pad plus a flag). So grab the actual to read its with checkpoint.PrimaryPart or checkpoint. When the touches it, you record that 's position as their new spawn point.
Why confirm GetPlayerFromCharacter before saving a checkpoint?
When the character dies, spawn them at their checkpoint instead of the default:
local function spawnPlayerAtCheckpoint(player)
local cframe = getCheckpoint(player)
if cframe then
player:LoadCharacter()
local character = player.Character
character:PivotTo(cframe)
else
-- no checkpoint yet — use the default spawn
player:LoadCharacter()
end
end
PivotTo sets the character model's position to the saved . There's a subtlety: LoadCharacter() returns instantly with a partly-loaded character, and the character may not be ready to move for a frame or two.
A common trick is to load the character and set the position on the next frame, once the character has actually loaded:
player:LoadCharacter()
task.wait()
local character = player.Character
if character then character:PivotTo(cframe) end
Connect the respawn logic to the death , exactly like the health-damage lesson:
local function onCharacterAdded(character)
local humanoid = character:WaitForChild("Humanoid")
humanoid.Died:Connect(function()
local player = Players:GetPlayerFromCharacter(character)
if player then
task.delay(3, function()
spawnPlayerAtCheckpoint(player)
end)
end
end)
end
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(onCharacterAdded)
end)
The flow: character dies → wait 3 seconds → load a new character at the 's last checkpoint. If they never touched a checkpoint, they get the default spawn. Either way, CharacterAdded fires for the new body and the whole system reattaches.
If your spawn logic already handles the default case, unify it: pre-seed every 's checkpoint to the default spawn at join time. Then spawnPlayerAtCheckpoint needs no special-case branch — it always has a valid .
Inside spawnPlayerAtCheckpoint, after loading the character, write the line that moves that new character to the saved checkpoint position.
local character = player.Character
-- move the character to the saved checkpointCheckpoints are three small pieces: recording, remembering, and respawning. Touching a checkpoint saves a by UserId. Dying looks up that and pivots the new character there.
-- Touch checkpoint → setCheckpoint(player, part.CFrame)
-- Die → getCheckpoint(player) → LoadCharacter → PivotTo
-- No checkpoint → default spawn
The same pattern scales: instead of a you can save a whole "respawn state" (which room, which flag, which zone) and restore it together. The checkpoint becomes your save-in-progress.
checkpoint.CFrame.UserId. A table keyed by object leaks memory and breaks on reconnect.Next: vehicles — weld together and drive.