Hello, I am trying to make an Admin panel that can teleport the admin to whatever server a player is in, the issue is I cant tell if the teleport failed or not. If it fails it end up messing the TeleportService for that player because it thinks the player is still teleporting. How can I cancel a failed teleport too?
Also is there a way to tell if the player is in a reserved server or just a public one?
I already have a Pcall set up, and the teleport failed screen like this does not get caught:
Edit: I am also trying to tell what kind of server the player is in without physically being in their server. So if they are in a Reserved Server I would need to use a different teleport function than if they are in a Public Server.
I looked through the TeleportService documentation a little more, and apparently there is a TeleportInitFailed event that fires on both the server and client when a player fails to teleport.
When teleporting a player to a server, you must have created the server in the first place, right? Or is that not how this works?
Yes, so I need to give some more context on whats going on and what im trying to achieve. The game works on a Lobby system that players join and then teleport somewhere. I am making an admin panel to where all the admin has to do is type in the players name and then they are able to join them. The issue is I dont know how to tell if the target player is in a reserved server or a private server. If the player is in a reserve server it requires a special teleport which is why im getting the teleport failed error I sent. I can look into the teleportintfailed to see what I can make of that.
If you’re able to get the ID of the server you are trying to teleport to (I assume you can), you can use the method listed below to try and determine the server type:
local TeleportService = game:GetService("TeleportService")
local function teleportPlayer(adminPlayer, targetPlayer)
local success, teleportResult = pcall(function()
return TeleportService:TeleportToPlaceInstance(targetPlayer.GameId, targetPlayer.PlaceId, adminPlayer)
end)
if not success then
-- if the teleport failed, cancel the teleport for the admin player
TeleportService:CancelTeleport(adminPlayer)
warn("Teleport failed for player "..adminPlayer.Name)
else
print("Teleport successful for player "..adminPlayer.Name)
end
end