I got a leaderboard to work which shows the world and stage, Now I want it that when I jump on a checkpoint the stage goes up on the leaderboard and when I die I spawn at the Checkpoint but I can't get it to work. I neither respawn at the checkpoint nor does the stage go up on the leaderboard.
Here is the code for the leaderboard:
game.Players.PlayerAdded:connect(function(player)
local leaderstats = Instance.new("Model")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local money = Instance.new("IntValue")
money.Name = "World"
money.Value = 1
money.Parent = leaderstats
local money = Instance.new("IntValue")
money.Name = "Stage"
money.Value = 1
money.Parent = leaderstats
end)
This is the code at the Spawnpoint/Checkpoint:
function onTouched(part)
name = script.Parent.Name
local h = part.Parent:FindFirstChild("Humanoid")
if h ~= nil then
char = h.Parent
player = char:GetPlayerFromCharacter(char)
if player ~= nil then
leaderstats = player.FindFirstChild("leaderstats")
if leaderstats ~= nil then
stage = leaderstats:FindFirstChild("Stage")
if stage ~= nil then
stage.Value = name
end
end
end
end
end
end
script.Parent.Touched:connect(onTouched) -- Links event to function
The only error I get is Workspace.1.Checkpoint System:18 Expected , got 'end' But I don't understand what it means...
The World is for when I add multiple worlds to the obby but I am not that far yet.
I hope someone can help. Thank you in advance!

3 comments
I changed the scripts as you said but still when I jump on the checkpoint it doesn't respawn me there if I die. Maybe I am doing something wrong in studio itself in the porperties?
you can check this link for more tutorial, https://www.youtube.com/watch?v=Aa83VYif6VA
you can also make this answer as a correct answer if you think this help you with your problem