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.
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.
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
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
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