Hi, so I'm pretty new to Lua and I need help with my script. So basically I'm just trying to make it so that I can teleport myself to specific coordinates. Here's my current script that I made to try and teleport myself to specific coordinates. But it won't work, and I keep on getting an error through my output saying "21:05:04.287 - Workspace.Script:1: attempt to index nil with 'position'" And I just don't know how to fix it, can someone please help me?
game.Players.LocalPlayer.position = Vector3.new(0, 0, 0)
-- The script that's giving me errors making it so that I can't make it teleport myself to specific coordinates.
You cant do LocalPlayer
in a script, (script = server, localscript = client) do it in a localscript instead
And you should use Position
instead of position
the latter has been deprecated
and player doesnt have .Position property, you need to reference the Character
which has a PrimaryPart
which does have .Position
property
And you should CFrame
property instead of Position
since the character uses weldcontraints and when u change the Position
it translates a new ofset for only that part, so it looks really weird
example as requested : localscript in StarterCharacterScripts
game.Players.LocalPlayer.Character.PrimaryPart.CFrame = CFrame.new(0,10000,0)
game:GetService("Players").LocalPlayer.Character:MoveTo(Vector3.new(-108.719, 4.132, -39.976))