Is there a way to wait for a teleport made from TeleportService is ready?
From what I know at the moment, you can check if a teleportation can be made successfully on the server and display the error message using pcall.
local CouldTeleportToPlayer, TeleportErrorMessage = pcall(function()
TeleportService:TeleportToPrivateServer(LeadershipPlaceID,ServerID,{Player})
end)
However, even when the teleport successful and is called, there is occassional lag (5-30 seconds) at most when the player is finally able to teleport into the game. I’m just wondering if it’s possible to check if the teleport is ready so I don’t teleport players unwantly.
local ClientIsPendingToJoin = HandleServerEvent:InvokeClient(Player, "CheckIfPendingToJoinServer")
I use this code on the server to make sure the player is waiting, but once TeleportService there’s nothing they can do to stop, even if they aren’t pending anymore which can spook people at times when they’re server browsing. I’m hoping if it’s possible to do something like this for example:
local ReadyToTeleport = TeleportService:TeleportToPrivateServer(LeadershipPlaceID,ServerID,{Player})
local ShouldTeleportPlayer = true
while ReadyToTeleport == false and ShouldTeleportPlayer == true do
local ClientIsPendingToJoin = HandleServerEvent:InvokeClient(Player, "CheckIfPendingToJoinServer")
if ClientIsPendingToJoin == false then
ShouldTeleportPlayer = false
end
wait()
end
if ReadyToTeleport == true and ShouldTeleportPlayer == true then
--Teleport tto place instantly now that we're done loading from TeleportService
end