For some reason, when I set my stage value to 0, my checkpoint system breaks, and when its at a 1 and my arrow seems to skip ahead by 1 stage at the start
Code:
local Checkpoints = game.Workspace.Checkpoints
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder", plr)
leaderstats.Name = "leaderstats"
local Checkpoint = Instance.new("IntValue", leaderstats)
Checkpoint.Name = "Stage"
Checkpoint.Value = 1
plr.CharacterAdded:Connect(function(character)
wait()
if Checkpoint.Value > 1 then
character:MoveTo(Checkpoints:FindFirstChild(Checkpoint.Value - 1).Position)
end
end)
end)
for i, v in pairs(Checkpoints:GetChildren()) do
v.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local char = hit.Parent
local plr = game.Players:GetPlayerFromCharacter(char)
local Checkpoint = plr.leaderstats.Stage
if tonumber(v.Name) == Checkpoint.Value then
Checkpoint.Value += 1
end
end
end)
end
Proof: