I am not trying to make a checkpoint, just a setting when you enable it, you teleport to your stage. There is a leaderboard for like stage 1, etc... I added this in my starter GUI, so when you enable the button, you automatically get sent to the stage when you die. But it isn't doing anything, even when enabled. Please help?
while true do
wait(0.01)
if script.Parent.Value == true then
game:GetService('Players').PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character:WaitForChild("Humanoid").Died:Connect(function()
local check = player.Parent:FindFirstChild("Humanoid") --Find the human that touched the button
local user = game.Players:GetPlayerFromCharacter(player)
local stats = user:findFirstChild("leaderstats")
if stats ~= nil then
local S = stats:findFirstChild("Stage").Value
if S == 1 then
user.Character.HumanoidRootPart.CFrame = CFrame.new(66, 5, -167)
end
if S == 2 then
user.Character.HumanoidRootPart.CFrame = CFrame.new(66, 33, -361)
end
if S == 3 then
user.Character.HumanoidRootPart.CFrame = CFrame.new(65, 44, -434)
end
if S == 4 then
user.Character.HumanoidRootPart.CFrame = CFrame.new(66, 44, -495)
end
if S == 5 then
user.Character.HumanoidRootPart.CFrame = CFrame.new(66, 44, -562)
end
if S == 6 then
user.Character.HumanoidRootPart.CFrame = CFrame.new(66, 44, -618)
end
if S == 7 then
user.Character.HumanoidRootPart.CFrame = CFrame.new(66, 47, -683)
end
if S == 8 then
user.Character.HumanoidRootPart.CFrame = CFrame.new(66, 44, -734)
end
if S == 9 then
user.Character.HumanoidRootPart.CFrame = CFrame.new(64, 80, -799)
end
if S == 10 then
user.Character.HumanoidRootPart.CFrame = CFrame.new(64, 80, -866)
end
if S == 11 then
user.Character.HumanoidRootPart.CFrame = CFrame.new(64, 80, -921)
end
if S == 12 then
user.Character.HumanoidRootPart.CFrame = CFrame.new(59, 80, -981)
end
if S == 13 then
user.Character.HumanoidRootPart.CFrame = CFrame.new(59, 80, -1045)
end
if S == 14 then
user.Character.HumanoidRootPart.CFrame = CFrame.new(59, 80, -1089)
end
if S == 15 then
user.Character.HumanoidRootPart.CFrame = CFrame.new(59, 80, -1165)
end
if S == 16 then
user.Character.HumanoidRootPart.CFrame = CFrame.new(59, 80, -1216)
end
if S == 17 then
user.Character.HumanoidRootPart.CFrame = CFrame.new(59, 80, -1235)
end
if S == 18 then
user.Character.HumanoidRootPart.CFrame = CFrame.new(59, 80, -1254)
end
if S == 19 then
user.Character.HumanoidRootPart.CFrame = CFrame.new(59, 80, -1339)
end
if S == 20 then
user.Character.HumanoidRootPart.CFrame = CFrame.new(59, 80, -1461)
end
if S == 21 then
user.Character.HumanoidRootPart.CFrame = CFrame.new(59, 80, -1533)
end
if S == 22 then
user.Character.HumanoidRootPart.CFrame = CFrame.new(59, 96, -1565)
end
if S == 23 then
user.Character.HumanoidRootPart.CFrame = CFrame.new(59, 96, -1626)
end
wait()
end
end)
end)
end)
end
end
No errors in f9, or Roblox studio, even the script "Go to script Error". Edit: This is a script, not a local. Also, it is located in StarterGui.frame.button etc...

1 comment
you dont put it in a while loop and you dont do it completely on the server, you have to handle the deaths in a local script and then fire to the server telling the player has died