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:
player1
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
player1.Character:MoveTo(player2.Character.HumanoidRootPart.Position)
end