Ad
Log in to vote
0

Teleporting a player to another player's position?

Asked by 9 days ago
Edited 9 days ago

Please include the code which you are trying to use, so the community will be better-equipped to help you with your problem.

I've been making a GUI with RemoteEvents and all which is supposed to teleport you to a desired player's position. The fact is I've done everything else, verified with print()s, but so far the closest I've got to actually moving the player is changing where the character is facing. Please let me know if you know how to move the character!

Edit: An admin left me a note to include some code, so here it is:

if targetTorso then
        print(targetTorso.Position)
        --Teleport the player, not done yet.        
        print("Target torso: " .. tostring(targetTorso.Position) .. " Admin torso: " .. tostring(adminTorso.Position))
end

Where adminTorso is the torso of the person who is trying to teleport, and targetTorso is the torso of the person who the admin is trying to teleport.

1 answer

Log in to vote
1
Answered by 9 days ago
Edited 9 days ago

Just check their character's CFrames and move one's HumanoidRootPart to the CFrame of the other.

The wiki has a good article on teleporting.

For teleporting one player to another, you can use something like this.


local function teleportPlayer(target,endPlayer) -- target will be teleported to endPlayer if target.ClassName == "Player" and endPlayer.ClassName == "Player" then -- check if they're both players local endPlayerCharacter = endPlayer.Character or endPlayer.CharacterAdded:Wait() -- make sure they have a character/wait for one if they don't, this is optional I guess target.Character:WaitForChild("HumanoidRootPart").CFrame = endPlayerCharacter:WaitForChild("HumanoidRootPart").CFrame -- position them end end
0
It worked, thanks! Earlier on I tried something like this, but accidentally set the CFrame of the Torso. Ultimate_Miner64 46 — 9d
Ad

Answer this question