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)

4 comments
That makes total sense, however, it still isn't working for some reason. I removed the LocalPlayer line, it still goes through all of the code, it just doesn't teleport the player as it should once they respawn.
Sure. I don't see anything wrong with it though.
So I ended up messing with the CFrame and it ended up working. Thank you!
np