Re-teleporting players to the same Place

Hey devs,
I’ve been making a system that re-teleports the players to the same place after the round is finished, but everytime it teleports me, it gives me this error :


I am not sure if this is my fault trying to do something that’s not possible (re-teleporting players to the same place) or Roblox having issues since, as you can see in the image, I am LITERALLY in the server when it gives me the error… Should I try making another system, teleport players to another place, or just wait because it might be a roblox bug ?

Script 1 :

local timeLeft = game.ReplicatedStorage.TimeLeft

local RoundRunning = false
local TeleportationModule = require(game.ServerScriptService.TpModule)


if RoundRunning == false then
	wait(5)

	RoundRunning = true
	print("round running")
	local secondPassed = 20
	while wait(1) do
		if secondPassed > 0 then
			secondPassed = secondPassed - 1
			timeLeft.Value = secondPassed
		elseif secondPassed == 0 then
			TeleportationModule.teleportWithRetry(7751149102, game.Players:GetPlayers())
			timeLeft.Value = 0
			print("The round's done")
			RoundRunning = false
			break
		end
	end
end

Script 2 (from the devhub):

local TeleportService = game:GetService("TeleportService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local TeleportModule = {}

local RETRY_DELAY = 2
local MAX_WAIT = 10

-- Create remote event instance
local teleportEvent = Instance.new("RemoteEvent")
teleportEvent.Name = "TeleportEvent"
teleportEvent.Parent = ReplicatedStorage

function TeleportModule.teleportWithRetry(targetPlaceID, playersTable, teleportOptions)
	local currentWait = 0

	-- Show custom teleport screen to valid players if client event is connected
	teleportEvent:FireAllClients(playersTable, true)

	local function doTeleport(players, options)
		if currentWait < MAX_WAIT then
			local success, errorMessage = pcall(function()
				return TeleportService:TeleportAsync(targetPlaceID, players, options)
			end)
			if not success then
				warn(errorMessage)
				-- Retry teleport after defined delay
				wait(RETRY_DELAY)
				currentWait = currentWait + RETRY_DELAY
				doTeleport(players, teleportOptions)
			end
		else
			-- On failure, hide custom teleport screen for remaining valid players
			teleportEvent:FireAllClients(players, false)
			return true
		end
	end

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

	-- Fire initial teleport
	doTeleport(playersTable, teleportOptions)
end

return TeleportModule

Thanks in advance !

I’m pretty sure it’s a roblox problem.

Because of the message, but I’ve never seen this before so I might be wrong.

2 Likes

Well, after a few more attemps, I got this error :

and when I re-tried after that it just kept loading forever…

1 Like

This is because if a server reaches 0 players noone will be able to rejoin the server no matter what, meaning that you would need it to create a new server after you rejoin. Although im not sure this is the case, I think it is trying to reconnect you to the same server and failing. Check if this error continues if there is another player playing the game at the same time as you.

1 Like

Well its not trying to rejoin the server, but the Place, so it should create a server no matter what right ?

1 Like

If you check the server list on the roblox website then you can see that there is still a server running with 0 players but you cannot join it. I think that is where it is trying to reconnect you.

I checked the servers running and there is no server running with 0 players…

Hmm… This is strange because this is what usually happens once everyone leaves a server, a 0 player server will appear, this only happens for a short period so maybe you were too slow, if not that then I am not too sure what the issue is.

1 Like