I just tried to make a brick that teleports you back to a position of (5, 5, 5), I tested in Play Solo mode and it works for around five time but then after that it doesn't work anymore. It gave me this error:
17:09:46.732 - Workspace.Part.Script:11: attempt to index global 'player' (a nil value) 17:09:46.733 - Stack Begin 17:09:46.734 - Script 'Workspace.Part.Script', Line 11 17:09:46.737 - Stack End
And here is my script
local isOn = false
target = CFrame.new(5, 5, 5)
function teleport(hit)
if not isOn then
isOn = true
name = hit.Parent.Name
player = game.Workspace:FindFirstChild(name)
player.Torso.CFrame = target
isOn = false
end
end
script.Parent.Touched:connect(teleport)

1 comment
Ok, thanks. It works now