TeleportAsync() experiencing a weird error?

I am experiencing this error when I try to re-teleport a player that failed to teleport. My best guess is it is coming from this code:

TeleportService.TeleportInitFailed:Connect(function(player, teleportResult, errorMessage, targetPlaceId, teleportOptions)
		if teleportResult == Enum.TeleportResult.GameNotFound then
			for _,v in pairs(CollectionService:GetTagged(player.Name.."TeleportObjects")) do
				v:Destroy()
			end
			self.Client.Teleporting:Fire(player,false)
			self.ProfileService:LoadProfile(player)
		else
			task.wait(2)
			self:_executeTeleportWithRetry(targetPlaceId,{player},teleportOptions) -- This is simply a pcalled teleportasync which will retry a few times
		end
	end)

I am not sure why I am getting a “specified payer is not a valid user” because it is clearly a player in the game?

The problem is exactly what the warning says: “A specified Player is not a valid User.”
One of the objects in the table of players you’re trying to teleport is simply not a player. Print out that table before teleporting and check for anything that isn’t a player.

I have already done this and validated that they are indeed a “Player” and exist inside “game.Players”. Printed results as expected.

When it fails to teleport me, It just retries until infinity and continues to throw this error when I am the only player left in the server.

Do you happen to be testing on studio by any chance? (probably not since you screenshotted the console)

testing was done in-game. This is why I am so confused by this error, and nothing about this error can be found on the wiki. What is a “valid user”? Because apparently a player inside the Players service isn’t valid!

I can also send my teleport code if that would help.

Yes, I’d ilke to see the teleport code.

function GameService:_executeTeleportWithRetry(placeId,playersTable,teleportOptions)
	local ATTEMPT_LIMIT = 5
	local attemptIndex = 0
	local success, result
	
	repeat
		success, result = pcall(function()
			return TeleportService:TeleportAsync(placeId, playersTable, teleportOptions)
		end)
		
		attemptIndex += 1
		if not success then
			task.wait(2)
		end
		
		print(attemptIndex,ATTEMPT_LIMIT)
	until success or attemptIndex == ATTEMPT_LIMIT

	if not success then
		warn("Teleport Failure:",result)
	end

	return success, result
end

In the code you showed on the first message, try printing player and see what it shows.

It prints the players name. I also did print(player.Parent) and it prints “Players”

you are teleporting “playersTable” and i assume its a table and not a player?

This is correct playersTable is a table

lemme check wait – 3 0 characters characters

The wiki stated TeleportAsync can accept a table of up to 50 players (and im only sending 30 MAX- its usually around 15)? And 90% of the time it works and it just sometimes leaves 1 or 2 players behind with the error I gave before

might be teleport errors, if it actually works for you and it leaves 2 players behind try doing it with a for loop and check if it works

is there any code behind the function that you could pass? could you print #game.Players:GetChildren() ?

I have added more debug code. Sadly this means I have to play dozens of games waiting for this error to occur again.

Update: It seems that TeleportInitFailed literally isnt even firing for me?

I have it set so TeleportInitFailed will print the player’s name… Myself and the other player in this server have been sitting here for 4 minutes and TeleportInitFailed has not fired for either of us??

I have added the code below (even though TeleportInitFailed should still fire)

for i,Player in pairs(playersTable) do -- Remove players that arent in-game anymore
			if Player.Parent ~= game:GetService("Players") then
				table.remove(playersTable,i)
			end
		end