I am in utter confusion as of right now. I have a supposed-to-be simple script here for an obby. The problem is, it won't teleport players back to the stage they were on, and it spawns them back at the start. It saves their level, but it doesn't teleport to the level they were on after they die. There are no errors, it goes through the entire script, including the print function at the very end. Please help me understand what is going on.
local player = game.Players.LocalPlayer game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(char) char:WaitForChild("Humanoid").Died:Connect(function() local spawnpointnum = player.leaderstats.Stage.Value local spawnpoint = game.Workspace.StageNumbers:FindFirstChild(tostring(spawnpointnum)) player.CharacterAdded:Wait() wait(1) char:MoveTo(spawnpoint.Position) print(player.Name .. " has died!") end) end) end)
Hello. There is only one problem in your code.
Problem:
Solution:
Fixed Code:
game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(char) char:WaitForChild("Humanoid").Died:Connect(function() local spawnpointnum = player.leaderstats.Stage.Value local spawnpoint = game.Workspace.StageNumbers:FindFirstChild(tostring(spawnpointnum)) player.CharacterAdded:Wait() wait(1) char:MoveTo(spawnpoint.Position) print(player.Name .. " has died!") end) end) end)