I am a bit confused about my script. Because the detecting part works perfectly and the teleport command is also logical, but I when I test it then it will detect if the player died but will not teleport the player to that location.
Here is my script (print(“Success!”) is because for testing if the detecting part works):
game.Players.PlayerAdded:Connect(function(player)
print(player)
local spawn = false
script.Parent.Touched:Connect(function(hit)
print("Success!")
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name == player.Name then
spawn = true
end
end)
player.CharacterAdded:Connect(function(character)
print("Success!")
if spawn == true then
print("Success!")
character.HumanoidRootPart.CFrame = CFrame.new(script.Parent.Position.X,script.Parent.Position.Y+5,script.Parent.Position.Z)
end
end)
end)
My script is a script, not a local or module script. If you know why it is not working, then please point it out for me. I do not need how to make a checkpoint, I just need why is this not working. If you know then please tell me, thanks.

3 comments
I know, but why is mine not working? Cuz mine is actually one of my friend's script, and he do not know why it does not work so he came and ask me why and I do not know so I came and ask this question.
I know how to make a checkpoint but just asking why is this one not working cuz it does not seem wrong.
I'm not familiar with teleporting and Vector, CFrames so I can't help you sry.