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)
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.
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)