It is possible to teleport a player to a defined player in another server?

The title is a bit self-explanatory, I want to know if you can teleport a player to a player with a defined name in another server, in my case, I would like to make a player searcher that works only in my game, and teleport the player who’s searching to the other player, I dont know if that’s possible to do, thanks for reading :slight_smile:

2 Likes

From the DevHub, it doesn’t seem like there is a way to teleport a player specifically to another public server (please correct me if I’m wrong). However, if you’re able to use TeleportService:ReserveServer(), and you want to be able to join a player who’s in one of these private servers, there is one way I can think of to join.

  1. Store the session of all playing users in a DataStore
    This is pretty straightforward, although it may impact your DataStore usage and may have some reliability issues. Essentially, whenever somebody joins a ReserveServer, add a value to a DataStore with the key being the target player’s userId and the Id of the server they are currently in. Something like: game:GetService("DataStoreService"):GetDataStore("ActivePlayers"):SetAsync(player.userId, game.PrivateServerId)
    You will also want to clear this value upon player leave.

  2. Find the session a user is in
    So after you log what ReserveServer each user is in, you’ll be able to look that up by their userId. To obtain a user’s userId from their name, you can use:
    local userId = game.Players:GetUserIdFromNameAsync(USER_NAME)
    Once you have the user’s userId, it’s as simple as looking that up in the DataStore
    local serverId = game:GetService("DataStoreService"):GetDataStore("ActivePlayers"):GetAsync(userId)

  3. Teleport the user!

game:GetService("TeleportService"):TeleportToPrivateServer ( PLACE_ID,  serverId,  {PLAYER_INSTANCE_YOU_WANT_TO_TELEPORT} )

Again, I don’t think this will work for public servers, so I’m not too sure if this will be applicable to your game. I think making a feature request for teleporting to players in public servers would be a good idea!

4 Likes

I’ve seen numerous games that have this feature, so it is possible, but I don’t have the answer you’re looking for, soo…