Teleport command help

You can use CFrame.lookat() to make the target HumanoidRootPart look at the player.More info about CFrame see here.

2 Likes

Hello, thank you for your reply.
I tried this, and it seemed to teleport the player to a random point.
Here is what I did:

char3.HumanoidRootPart.CFrame = CFrame.lookAt(char4.HumanoidRootPart.Position, char3.HumanoidRootPart.Position)

2 Likes

Here, I fixed it.

char3.HumanoidRootPart.CFrame = CFrame.lookAt((char4.HumanoidRootPart.CFrame * CFrame.new(-3, 0, 0)).Position, (char3.HumanoidRootPart.CFrame).Position)
1 Like

Sorry, I thought it worked. It works from where I was standing but when I moved somewhere else and tried it, it went a different direction.
Thank you.

2 Likes

Humm, you just want to teleport player to infront player, that script should work. What was the direction of the person get teleport? Can you show me a picture?

1 Like

Yes. Here’s a picture:


Thanks again.

What I’m trying to do is have them face to face*

1 Like

Damn, I guess we will have to set the angles manually instead of automatic.

2 Likes

How would we go about doing that?

1 Like

You could get the person who issued the teleport commands CFrame rotation, then set the other player rotation of -180 of the player teleporting them.

1 Like

That will make the user looking the issuer, but not face to face. Thank you anyway.

1 Like

I thought by face to face you mean the player looking at the person who teleported them?

1 Like

Oh sorry, I will make that clearer, but I did add an image.

I’ve did a research and I found a post that should help you with, you can make Target is the HumanoidRootPart of player who teleported and the character is the person who get teleported.The post that I recommended to read is here.
EDIT : Take the second answer, that should solve your problem.

1 Like

Right, so in your image you want both of them facing eachother, thats what that will do.
Here, I will clear it up:
Get issuers CFrame Rotation
Do a difference of (0,180,0) to make it so that the returned CFrame will cause the rotation of the player to be looking at the issuer.
Apply the CFrame rotation to the person being teleported.
EDIT:
By difference I mean a calculation which will return the desired rotation, but you can just take the above reply

1 Like

His script doesn’t work, it teleported me to a random spot like my script.

1 Like

Oh, you are trying to simply get a player to TP infront of another player and face them?
Okay, one moment

EDIT:
Looked at some other posts, the easiest way to offset a CFrame set is like this:

local offset = Vector3.new() -- you might want to do Vector3.new(-3,0,3) based off of what I saw in script
char3.HumanoidRootPart.CFrame = char4.HumanoidRootPart.CFrame*CFrame.new(offset)

You said its teleporting to a random location, right? Could you try this instead?
Or did you mean rotation?

I’m confused on what you are really trying to do, but looking at your code, this should hopefully work.

And then after this, you can set the rotation.

1 Like

Hello! Thanks again for your reply. I tried this and it TP’s the player beside it in front of it or behind it depending on where your standing. I’m looking for it to always be in front.

After fooling around with it for an hour or 2 I finally found something I’m happy with. It’s not exactly what I wanted, but it’s good enough. This one teleports you in front of the player, but not face to face. Here is what I used:

char3.HumanoidRootPart.CFrame = char3.HumanoidRootPart.CFrame * CFrame.new(-4, 0, -4)

Thank you for all your help, for those who helped me. :smiley:
@OriChanRBLX
@epicduck410

2 Likes

Update #2
Turns out the last one didn’t work. It only worked in one position.
So kept trying and trying. And I figured it out, this is what it looks like:

local offset = Vector3.new(0,0,5)
char3.HumanoidRootPart.CFrame = char4.HumanoidRootPart.CFrame * CFrame.Angles(0, math.rad(180), 0)*CFrame.new(offset)

Again, thanks to everyone who helped.
@OriChanRBLX
Hopefully this is the last time I need to do this lol

1 Like

I guess, but your offset was wrong, and you didn’t rotate it. Please don’t take credit for something you didn’t do, that very rude!