How can I write a simple checkpoint script for my obby game? (one that saves so if the player leaves and comes back they’re where they left off)
Keep in mind I am not an advanced scripter by any means -
How can I write a simple checkpoint script for my obby game? (one that saves so if the player leaves and comes back they’re where they left off)
Keep in mind I am not an advanced scripter by any means -
So first of all make a folder in the workspace called checkpoints and put all the checkpoints in there calling them checkpoint1, checkpoint2…you get the idea
In serverScriptService make a leaderstats script that makes a IntValue called “Stage”
Next add a script in ServerScriptService and call it CheckpointHandler
for i, checkpoint in pairs(game.Workspace.Checkpoints:GetChildren) do
checkpoint.Touched:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
plr.leaderstats.Stage.Value = i
end
end
end
Then to make it save follow this YouTube video I made: