I need help with my teleporter. Basically it was made so if a brick is touched a Popup GUI will appear and the player will switch games, but for some reason it crashes the client instead. Here the code
Teleporter
function onTouched(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
game:GetService("TeleportService"):Teleport(5653600014,player)
end
end
script.Parent.Touched:connect(onTouched)
GUI
Sound = script.Parent.Scream
Popup = script.Parent.Popup
Ready = true
function onTouch(hit)
local h = hit.Parent:FindFirstChild("Humanoid")
if h ~= nil and Ready == true then
Ready = false
local plyr = game.Players:FindFirstChild(h.Parent.Name)
local c = Popup:clone()
c.Parent = plyr.PlayerGui
script.Parent.Scream:play()
wait(222)
c:remove()
wait(1)
Ready = true
end
end
script.Parent.Touched:connect(onTouch)
I tried to combine them but still crashes the client. Here the link: https://www.roblox.com/games/5664353175/Teleporter-test
Combined script
function onTouched(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
game:GetService("TeleportService"):Teleport(5653600014,player) --replace the numbers with your place id
end
end
script.Parent.Touched:connect(onTouched)
Sound = script.Parent.Scream2
Popup = script.Parent.Popup
Ready = true
function onTouch(hit)
local h = hit.Parent:FindFirstChild("Humanoid")
if h ~= nil and Ready == true then
Ready = false
local plyr = game.Players:FindFirstChild(h.Parent.Name)
local c = Popup:clone()
c.Parent = plyr.PlayerGui
script.Parent.Scream2:play()
wait(222)
c:remove()
wait(1)
Ready = true
end
end
script.Parent.Touched:connect(onTouch)

2 comments
Shoot, I should've know from Scream:Play() that it wasn't going to be pleasant. Got me good lol. Sound was up and everything. However, can you please put the full "combined" script so it's easier to diagnose what the problem is?
Sure thing! I added it to the question.