My teleport isn't working (Teleport failed because The previous teleport is in processing)

I’m making a simple script that teleports players from the game place to main lobby place.
Here is my script:

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

local LOBBY_PLACE_ID = 4287394397
local backToLobby = workspace.Lobby.GoBackToLobby

backToLobby.Touched:Connect(function(touch)
	if touch.Parent:FindFirstChild("Humanoid") ~= nil then
		local player = Players:GetPlayerFromCharacter(touch.Parent)
		if player then
			TeleportService:Teleport(LOBBY_PLACE_ID, player)
		end
	end
end)

When I step onto the teleport area, this error keeps popping up over in the console. I don’t have any teleports in process currently. It teleports me after tens of seconds. I don’t want that delay into my game. How could I fix this?

I have tried looking from DevHub and there is nothing about this error.

1 Like

That’s because every time you touch the block, a teleport call is performed. This error is being thrown as expected. The wait time before a teleport occurs is also something you cannot change.

You can implement a dictionary that stores a list of players who have touched the block and add a check in that dictionary for the player as a condition for the if statement. Use TeleportInitFailed to clear off the player from the dictionary if the teleport fails, as well as PlayerRemoving.

5 Likes