local function SafeTeleport(placeId, reservedServerAccessCode, players, options)
local attemptIndex = 0
local success, result
reservedServerAccessCodeGlobal = reservedServerAccessCode
repeat
success, result = pcall(function()
return TeleportService:TeleportToPrivateServer(placeId, reservedServerAccessCode, players, options)
end)
attemptIndex += 1
if not success then
task.wait(RETRY_DELAY)
end
until success or attemptIndex == ATTEMPT_LIMIT
if not success then
warn(result)
end
return success, result
end
local function handleFailedTeleport(player, teleportResult, errorMessage, PlaceId, teleportOptions, reservedServerAccessCode, players)
if teleportResult == Enum.TeleportResult.Flooded then
task.wait(FLOOD_DELAY)
elseif teleportResult == Enum.TeleportResult.Failure then
task.wait(RETRY_DELAY)
else
error(("Invalid teleport [%s]: %s"):format(teleportResult.Name, errorMessage))
end
local players = {player}
SafeTeleport(PlaceId, reservedServerAccessCode, players, teleportOptions)
end
TeleportService.TeleportInitFailed:Connect(function(player, teleportResult, errorMessage, PlaceId, teleportOptions)
table.insert(failedPlayers, player)
handleFailedTeleport(player, teleportResult, errorMessage, PlaceId, teleportOptions, reservedServerAccessCodeGlobal, {player})
end)
return SafeTeleport
what's the issue with this teleport script? btw, this is modified off of roblox docs' teleport script
** You are now Level 1! **