Hey! I have a problem with a script in a button: I want to, when the button is clicked, reset the leaderboard stats (put stage to 0) and kill the player to come back to the spawn. Theres is the scripts: The button script (who dont work):
local leaderstats = Instance.new("Folder")
local button = script.Parent
local checkpoints = workspace:WaitForChild("Checkpoints")
game.Players.PlayerAdded:Connect(function(player)
local stage = Instance.new("IntValue")
button.MouseButton1Click:Connect(function()
stage.Value = 0
stage.Parent = leaderstats
button.MouseButton1Click:Connect(function(Hit)
Hit.Parent.Humanoid.Health = 0
end)
end)
end)
The leaderboard and stage script:
local checkpoints = workspace:WaitForChild("Checkpoints")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local stage = Instance.new("IntValue")
stage.Name = "Stage"
stage.Value = 0
stage.Parent = leaderstats
player.CharacterAdded:Connect(function(char)
local hum = char:WaitForChild("Humanoid")
wait()
char:MoveTo(checkpoints[stage.Value].Position)
hum.Touched:Connect(function(hit)
if hit.Parent == checkpoints then
if tonumber(hit.Name) == stage.Value + 1 then
stage.Value = stage.Value + 1
end
end
end)
end)
end)
Thanks in advance for your help!

2 comments
TY, it work very well.
No problem.