Is there a way to check if Teleport is Ready?

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


You can use game:IsLoaded() function, so basically, when the game is loaded for the client, maybe you can use Teleport With Gui, and then, use Messaging Service to let the know the other script you’ve teleported thanks to game:IsLoaded()

The only thing you are able to check is if a teleport failed to start using TeleportInitFailed. I would suggest just making a screen indicating their teleport is pending whenever they click a server to enter and then use this function to clear off the pending message if it fires with a valid failure to teleport.

4 Likes