I made a checkpoint system and it works. Whenever the player passes over the block it goes to the leaderstats and adds 1. Not only does it add +1 it will also save you progress so if you die you respawn there. The problem is that if I die and just 1 part of the body hits the block it counts it and does +1 and saves your progress. I want it so you have to be alive and walk over it and it gives the checkpoint. Note: I have a folder named checkpoints parts in it.
local checkpoints = workspace:WaitForChild("Checkpoints")
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = plr
local v = Instance.new("IntValue")
v.Name = "Stage"
v.Value = 1
v.Parent = leaderstats
plr.CharacterAdded:Connect(function(char)
local hum = char:WaitForChild("Humanoid")
wait()
char:MoveTo(checkpoints[v.Value].Position)
hum.Touched:Connect(function(hit)
if hit.Parent == checkpoints then
if tonumber(hit.Name) == v.Value +1 then
v.Value = v.Value +1
end
end
end)
end)
end)

1 comment
There's a thing called Debounce. (Cooldown).