If the player is too far away from the other he will be teleported

I want to try to make a script, in which if one player moves away from the other by a certain distance the player is teleported back to the other player:

I will give an example:

  1. player1
  2. player2

If player1 is too far away from player2, player1 is teleported to player2

You can use player:DistanceFromCharacter() and check if the player is too far away. Although you might wanna add checks to consider which player to move.

if player1:DistanceFromCharacter(player2.Character.HumanoidRootPart.Position) >= maximumDist then

Okay, I’ve had some tests and it worked, thank you very much.

1 Like