Currently you can get any checkpoint, whether it's behind you, or 5 stages ahead of you, I want to make it so that only the next stage's checkpoint can be gotten. Here is my checkpoint script in ServerScriptService:
local Players = game:GetService('Players')
Players.PlayerAdded:Connect(function(player)
local stage = player:WaitForChild("leaderstats"):WaitForChild('Stage')
player.CharacterAdded:Connect(function(character)
local checkpoint = game.Workspace.Stages:FindFirstChild(stage.Value)
delay(.01, function()
character:SetPrimaryPartCFrame(checkpoint.CFrame + Vector3.new(0,10,0))
end)
end)
end)
And here is the checkpoint script that goes in with my stages in the "Stages" folder:
for i,v in pairs(script.Parent:GetChildren()) do
if v:isA("Part") then
v.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChild("Humanoid").Health >= 1 and v.Name ~= "0" then
game.Players:FindFirstChild(hit.Parent.Name).leaderstats.Stage.Value = v.Name
end
end)
end
end

3 comments
Didn't work
was an error in code, fixed it.
Worked, thanks!