Hi, I was trying to patch a bug in my game but also made another one, When I test the game in studio, it says I’m on stage 2 instead of stage 1,
here’s proof:
And here’s my code:
local Checkpoints = workspace.Checkpoints
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder",player)
leaderstats.Name = "leaderstats"
local Checkpoint = Instance.new("IntValue",leaderstats)
Checkpoint.Name = "Stage"
Checkpoint.Value = 1
player.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 character = hit.Parent
local player = game.Players:GetPlayerFromCharacter(character)
local Checkpoint = player.leaderstats.Stage
if tonumber(V.Name) == Checkpoint.Value then
Checkpoint.Value += 1
end
end
end)
end
can anyone help me?