Hello, greeting to you and thanks for coming. What I am doing is to script a checkpoint. The script did not work, when I run it, it does not output any errors, but just not working. I checked the reason by using a print(“success”) function and found out it is the CFrame part’s error, but I do not know where is the mistake, anyone can point it out for me?
Here is my script:
game.Players.PlayerAdded:connect(function(player)
spawn = false
script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name == player.Name then
spawn = true
end
end)
player.CharacterAdded:connect(function(respawn)
if spawn then
player.Character.HumanoidRootPart.CFrame = CFrame.new(script.Parent.Position.X,script.Parent.Position.Y+5,script.Parent.Position.Z)
-- It is the problem of here.
end
end)
end)
My script is a normal script, it is not a localscript or modulescript.
If you know where is the mistake then please tell me, thanks.

7 comments
Yeah, but, can you just please tell me why is my script not working and not returning any errors?
I do understand why is your code working, what I am wondering is why is my script not working.
I edited my answer to explain why yours doesnt.
thx
Hi, I am still a bit confused, because even though I changed spawn into spawn == true and locales the spawn it still does not work.
hello?
Your code itself is not going to work as I stated. You will have to recode the entire thing, which I did for you. Compare my script and your script and see where you can make improvements in future code.