It is sometimes remove the Gui and sometimes not. Just need some help. Quick and Easy :)

local debounce = false

script.Parent.TouchEnded:connect(function(hit)
    if debounce == false then debounce = true
        if hit then
            local chr = hit.Parent
            local plr = game.Players:GetPlayerFromCharacter(chr)
            if plr.PlayerGui:FindFirstChild("TeleportGui") then
                plr.PlayerGui.TeleportGui:Remove()
            end
        end
    wait(1)
    debounce = false
    end
end)

Update

I tried this script it work but still shows attempt to index local 'Something' (a nil value)

script.Parent.TouchEnded:connect(function(hit)
        if hit then
            local chr = hit.Parent
            local plr = game.Players:GetPlayerFromCharacter(chr)
            if plr.PlayerGui:FindFirstChild("TeleportGui") then
                plr.PlayerGui.TeleportGui:Remove()
            end
        end
end)

3 comments

0

There is no "Something" in this script. Show us the right script.

0

Like Programical already said, there is no "Something" in the Script. Also don't use ":Remove()", it got deprecated. Use ":Destroy()" if you want to get rid of it forever. And use "plr.PlayerGui.TeleportGui.Parent = nil" if you want to access it later on.

0

ACTUALLY SAY THE CLEAR OUTPUT ITS MAKES IT EASIER .