How would I teleport players in front of their position

Hi, I have a question for scripting. So I am a programmer and for a while I was wondering how to be able to teleport players in front of specific things or how to calculate locations in front of a player.

For example. I want to make a script that teleports players in front of them by 10 studs. BUT for that I would need to know if the player is facing the X Axis or the Z Axis.

and another example I need help with, is how would I be able to teleport a player in front of a part or in this case a dummy. How do I calculate the location and get the x/z axis to match the location it needs to be teleported?

Here’s an example of what I am trying to achieve:

I’ve started scripting a long time ago and this mystery really bothers me as I’m trying to create games.

When you want to teleport something infront of another object X amount of studs, you’d primarily need to know where the object is that you want to teleport around and the direction you want to go.

In your case you would simply use the CFrame of the larger dummy’s HumanoidRootPart.

Get the Position and LookVector from that CFrame, multiply the LookVector with a number (that would be the distance), and add the multiplied LookVector to the position to get a new position infront of the large dummy.

1 Like

thank you <3 I will try that now

2 Likes

Thanks m8 you really helped me out here <3

1 Like