These are the codes:
function Change() _G.Checkpoint = script.Parent end script.Parent.Touched:connect(Change)
Next one:
function onPlayerEntered(newPlayer) newPlayer:WaitForChild("Torso").CFrame = _G.Checkpoint.CFrame end game.Players.ChildAdded:connect(onPlayerEntered) function onPlayerRespawned(newPlayer) h = newPlayer:WaitForChild("Torso") if h ~= nil then h.CFrame = _G.Checkpoint.CFrame end end game.Workspace.ChildAdded:connect(onPlayerRespawned)
I'm trying to make a non-leaderstat checkpoint system, like if I were to just copy the same block over and over, the checkpoints would still work.
Errors:
Workspace.Script:9: Attempt to index field "Checkpoint" (a nil value)
Unlike local Variable, global Variable takes time to load so I suggest added a wait before line 9 to make sure the script doesn't run before the global variable has loaded.
function onPlayerEntered(newPlayer) newPlayer:WaitForChild("Torso").CFrame = _G.Checkpoint.CFrame end game.Players.ChildAdded:connect(onPlayerEntered) function onPlayerRespawned(newPlayer) h = newPlayer:WaitForChild("Torso") if h ~= nil then wait(2) h.CFrame = _G.Checkpoint.CFrame end end game.Workspace.ChildAdded:connect(onPlayerRespawned)