So basically, I’m trying to make an admin command which teleports the admin to a server depending on if a specific player is in the server
For example:
Admin is in server 1 and Player is in a different server, the admin can use a command to teleport to Player’s server using Player’s name or Player’s userid whichever one works.
I haven’t tried to script any of this yet since I have no idea where to start or what to even do.
You can have a go at using MessagingService, where you can send the relevant details of the user you are looking for to all other servers, and have the server which finds the player send the message to all servers saying the search was successful, including the Jobid, where the server initially making the request can listen out for this response. Then, you can use TeleportToPlaceInstance to take the admin to the server, or return an error if no message was received by other servers within a timeframe.
local ms = game:GetService("MessagingService")
function requestTeleport(player: Player, targetPlayerName: string)
ms:PublishAsync("FollowPlayer", {player.Name, targetPlayerName})
end
ms:SubscribeAsync("FollowPlayer", message)
local player = game.Players:FindFirstChild(message[2])
if player then
ms:PublishAsync("Response", {game.JobId, message[1], game.PlaceId})
end
end)
ms:SubscribeAsync("Response", message)
local player = game.Players:FindFirstChild(message[2])
if player then
local options = Instance.new("TeleportOptions")
options.ServerInstanceId = message[1]
game:GetService("TeleportService"):TeleportAsync(message[3], {player}, options)
end
end)