How to stop roblox crashing when teleporting to other places?

This is probably really easy to solve but I couldn’t find anything about it. (Maybe I didn’t look through the devforum enough.)

Whenever I touch the brick it says “exception while signaling: Cannot Teleport in the Roblox Studio. (x61)”.

Now, that’s not the problem here, the problem is the “(x61)”. Whenever I touch the brick it gives me 15 of those errors. I’ve had it happen before and it crashes Roblox. I’ve tried adding “wait(15)” but it didn’t work. How can I solve this?

local TeleportService = game:GetService("TeleportService")
local gameID = 6372331513

local function onPartTouch(otherPart)
	local player = game.Players:GetPlayerFromCharacter(otherPart.Parent)
	if player then
		TeleportService:Teleport(gameID, player)
	end
end

script.Parent.Touched:Connect(onPartTouch)

That just means you cannot teleport to other places in Studio. Use this service only in the game.

home tab > game settings > security > allow third party teleports

@4ef, I’ve already done that.

@GrayzcaIe, I know.

The problem is that it gives me too many error messages and it crashes Roblox in-game.[Not in Studio.] So how would I make it so it only gives me 1 error message instead of 64x? Or does that have nothing to do with it freezing/crashing?

The touched event fires multiple times, that’s probably the cause. Perhaps you could try adding a debounce so it only fires the first time for each player.

1 Like

I dont think a cooldown is even required. You should only teleport the player once.

Then they touch the button again when they rejoin and get teleported once.

local TeleportService = game:GetService("TeleportService")
local gameID = 6372331513


local Blacklist = {}
local function onPartTouch(otherPart)
	local player = game.Players:GetPlayerFromCharacter(otherPart.Parent)
	if player then
		if Blacklist[player.UserId] ~= nil then
			return
		end
		Blacklist[player.UserId] = true
		TeleportService:Teleport(gameID, player)
	end
end
script.Parent.Touched:Connect(onPartTouch)


game.Players.PlayerRemoved:Connect(function(Player)
	Blacklist[Player.UserId] = nil
end)

Welp, alright. I fixed it, thanks to everyone that replied. I’ll just mark @kylerzong’s reply as the solution since that also worked.