Teleportation Distance Limitations

I’m trying to make a teleport script with a limit on distance. However when I add the limit, it just stops you from teleporting all together. So I wanted it to be that it would teleport you in the direction you wanted, but only to your teleport distance.

I basicly just need the equation for this, I’ve been searching and can’t find it anywhere.
I’ve already done the keybinding and stuff.

2 Likes

Try using Magnitude

if (player.Position-Teleport.Position).magnitude < teleportDistanceLimit then

Something like that.

1 Like

I already have that I’m talking about how to calculate what happens with the distance is too far away.
When its too far I want it to still teleport you but only teleport you the max distance your allowed.

1 Like

You can check if the number has exceeded past the limit and if it did, it’ll teleport them to the highest distance.

1 Like