TeleportService issue

Hello. I seem to be encountering an odd bug relating to the TeleportService. I’m trying to teleport a group of players from one place to another (under the same universe). The module I’m currently using is a slightly altered version of the example module provided by Roblox. Here it is:

Code
-- Services --
local TeleportService = game:GetService("TeleportService")

-- Variables --
local TeleportModule = {}

local RETRY_DELAY = 2
local MAX_WAIT = 20

-- Main Functions --
function TeleportModule.safeTeleport(targetPlaceID, playersTable, teleportOptions)
	local currentWait = 0

	local function doTeleport(players, options)
		if currentWait < MAX_WAIT then
			local success, errorMessage = pcall(TeleportService.TeleportAsync, TeleportService, targetPlaceID, players, options)
			if not success then
				warn(errorMessage)
				task.wait(RETRY_DELAY)
				currentWait = currentWait + RETRY_DELAY
				if doTeleport then
					doTeleport(players, teleportOptions)
				end
			end
		else
			return false
		end
	end

	TeleportService.TeleportInitFailed:Connect(function(player, teleportResult, errorMessage)
		if teleportResult ~= Enum.TeleportResult.Success then
			warn(errorMessage)
			task.wait(RETRY_DELAY)
			currentWait += RETRY_DELAY
			if doTeleport then
				doTeleport({player}, teleportOptions)
			end
		end
	end)

	doTeleport(playersTable, teleportOptions)
end

return TeleportModule

The issue with this is that, when teleporting players, the module will mostly always warn “The previous teleport is in processing” or “Unknown exception.” or even “Third party teleport protection was unable to confirm safety of teleportation place.” Does anyone have any idea why this might be happening?

Any help would be greatly appreciated!

You need to enable 3rd party teleport provisions on both places (the teleport source place and the teleport destination place).

2 Likes