Hey, so I am using a teleport script made by Roblox to teleport players to a reserved server (similar to a camping game).
local module = {}
local TeleportService = game:GetService("TeleportService")
local ATTEMPT_LIMIT = 5
local RETRY_DELAY = 1
local FLOOD_DELAY = 15
function module.SafeTeleport(placeId, players, options)
local attemptIndex = 0
local success, result -- define pcall results outside of loop so results can be reported later on
local TeleportResult
repeat
success, result = pcall(function()
local TeleportingPlayer = TeleportService:TeleportAsync(placeId, players, options)
print(TeleportingPlayer)
TeleportResult = TeleportingPlayer
return TeleportingPlayer -- teleport the player 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
print(TeleportResult)
return success, TeleportResult
end
return module
TeleportAsync() should return TeleportResults which I then use to send players to the same server. But pcall doesn’t return that so I set the results to a variable but when printing the variable/results it just returns nil?