wait(1) local spawn = script.Parent spawn.Touched:connect(function(hit)
game.Players.LocalPlayer.Character.Torso.CFrame=CFrame.new(Vector3.new(192.713, 7.374, -898.129))-- Teleport end)
thats the code, but it only works when im in studio mode. when i play the real game out oif studio mode it doesnt teleport me why??
The problem is that you are trying to index LocalPlayer
from a normal Script. You should use GetPlayerFromCharacter
, and use hit
.
script.Parent.Touched:connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) player.Character.Torso.CFrame = CFrame.new(Vector3.new(192.713, 7.374, -898.129)) end)
Also, please format your code next time. If this helped, please up vote and accept answer. If this didn't help, please explain in the comments.