Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make a script that will teleport myself, or others that uses it, to a specific coordinate?

I want a script for roblox that I can execute that will teleport me to specific coordinates in the map. I have asked for help in other places and I have found this:

game.Players.playerName.Character.HumanoidRootPart.CFrame = CFrame.new(x, y, z)
--or
game.Players.playerName.Character.HumanoidRootPart.CFrame = game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame
--to teleport it to your coordinates

But I don't understand it and I want to use game.Players.LocalPlayer so anyone can use it. I am not very good at scripting so I don't really know what I am talking about but I think I am explaining what I want.

Thank You

1 answer

✓ Accepted answer

Your script should transport the humanoidrootpart to your desired position. Set X to the x coordinate of your dest, Set Y to the y coord, Z to z coord.

local x = 0
local y = 100
local z = 0
game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = CFrame.new(x, y, z)

Note that transporting your Head or limb would break the joints and sometimes kill the player, you can avoid this by teleporting humanoidrootpart, or torso if humanoidrootpart is not in the character. Alternatively you can use the MoveTo() function like this.

local x = 0
local y = 100
local z = 0
game.Players.LocalPlayer.Character:MoveTo(Vector3.new(x, y, z))

With MoveTo(): if a part is obstructing the destination, then your character would be moved to the topmost area that has the space for no collisions.

This discussion is preserved as it was. New answers, comments, and votes are closed.