TeleportInitFailed, Please help me with this

Hey everyone, I really need suggestions, approaches on this topic, please help.

TeleportService use to fail, with TeleportInitFailed we can get that fail and retry.
What could I expect if the game is receiving thousands of players? I mean, each server will contain max 25 players, but, how reliable would be using a system like this (similar to the Roblox Hub example of SafeTeleport module (script at the bottom)) while most of those players will try to perform a teleport to another place, handled by SafeTeleport module.

  1. If a player push a button on GUI, that triggers a RemoteEvent, Server handles the teleporting using the SafeTeleport module, there is a risk of TeleportService gets flooded? Maybe the entire server (25 players will perform the teleport, at different moments, or inmediately after join, they are not a group, they join at different times when joining game from website/app/deskApp)

  2. Whats the most reliable way you could suggest to handle any issue and get consistent teleports? Please I really need help with this, examples, experiences anyone had in the past, suggestions

Its extremely important that all those incoming players gets a succesful teleport…

This is the module in Roblox Hub about SafeTeleport, and I would be using a very similar approach:

local TeleportService = game:GetService("TeleportService")

local ATTEMPT_LIMIT = 5
local RETRY_DELAY = 1
local FLOOD_DELAY = 15

local function SafeTeleport(placeId, players, options)
    local attemptIndex = 0
    local success, result -- define pcall results outside of loop so results can be reported later on

    repeat
        success, result = pcall(function()
            return TeleportService:TeleportAsync(placeId, players, options) -- teleport the user in a protected call to prevent erroring
        end)
        attemptIndex += 1
        if not success then
            task.wait(RETRY_DELAY)
        end
    until success or attemptIndex == ATTEMPT_LIMIT -- stop trying to teleport if call was successful, or if retry limit has been reached

    if not success then
        warn(result) -- print the failure reason to output
    end

    return success, result
end

local function handleFailedTeleport(player, teleportResult, errorMessage, targetPlaceId, teleportOptions)
    if teleportResult == Enum.TeleportResult.Flooded then
        task.wait(FLOOD_DELAY)
    elseif teleportResult == Enum.TeleportResult.Failure then
        task.wait(RETRY_DELAY)
    else
        -- if the teleport is invalid, report the error instead of retrying
        error(("Invalid teleport [%s]: %s"):format(teleportResult.Name, errorMessage))
    end

    SafeTeleport(targetPlaceId, {player}, teleportOptions)
end

TeleportService.TeleportInitFailed:Connect(handleFailedTeleport)

return SafeTeleport

Any suggestion please, Im worried about this a lot u ,u

Well, as mentioned, if the service gets flooded, it will error out, delay longer, and try again. If it failed for a different reason, then it will wait the shorter time before trying again. If there was some different error (like an invalid place ID), then it will error out and not try again. Personally, I wouldn’t worry about it since you are using Roblox’s sanctioned code. If there is a problem with it, report it as a bug.

I believe the maximum number of people that can be teleported at one time is 40, so if you have 25 people, I think you’re safe.

1 Like

Thank you so much for your advice! I really appreciate it coming from your experience
Yup there’s limits when trying to teleport a group, in this case, its the player who decides to trigger the teleport by using a button, so it would be separated tasks, that would make any difference?

If you’re doing a game with a lobby, I would personally use a timer to teleport everyone as a group. But that’s me.

Nope, theres no lobby, ppl join directly into a round-based game, directly into action.
But will be a button to teleport players to a new place due to an important update, and probably most of the players will decide to teleport there, but we cant turn the new place as the starting place.

Each player should decide when to teleport.

I see. Do what’s best for you. Hopefully it works out for you.

1 Like

Thank you! I hope so, but still confused, just another question.

Theres a max of 50 players that can be teleported at one time. But… That means that if 51 players trigger “their own” Teleport via the SafeTeleport module, that will cause flooding? (using TeleportAsync() from server not client)
I mean, they are not a group being handled by the same Teleport thread, would be 51 separated teleports… that could cause the flood error too?

I’m not sure. I don’t think so unless they all trigger the teleport at the same time. That might cause some issues. Beyond that, not sure.

1 Like

Are you having problems with this happening? I’ve never seen a teleport script try so hard to avoid this. Pretty sure there is nothing more you can do. Other than straight-up limiting how many can even port around the same time period.

Sorry wrong person. I meant Dev_Peashie

1 Like

The teleport script that he’s using was written by Roblox themselves. It’s in the teleport documentation.

You can tell. Covers all you can.

Yup, Im hoping for the best with that :yum:
And exploring possible things just to be sure