Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Gui when touch remove not working?

Asked by
duckyo01 120
9 years ago

I tried making a gui that pops up when you touch a brick and I put a wait 5 seconds and remove the gui but it does not work. Heres what I put

GUI = game.Lighting.TryAgain
script.Parent.Touched:connect(function (hit)
if hit.Parent and game.Players:FindFirstChild(hit.Parent.Name) then
Play = game.Players[hit.Parent.Name]
if Play:FindFirstChild("PlayerGui") and not Play.PlayerGui:FindFirstChild(GUI.Name) then
GUI:Clone().Parent = Play.PlayerGui
wait(5)
GUI:remove()--here's where it does not work it would keep the gui there
end
end
end)
0
It is not removing the Cloned 'GUI', it is removing the original, consider using a Variable/Identifier? http://wiki.roblox.com/index.php?title=Variable TheeDeathCaster 2368 — 9y
0
I don't understand that duckyo01 120 — 9y

1 answer

Log in to vote
1
Answered by
Lacryma 548 Moderation Voter
9 years ago

As previously stated, the problem is that you are referencing the original GUI, not the copied version.

Solution

GUI = game.Lighting.TryAgain

script.Parent.Touched:connect(function (hit)
    if hit.Parent and game.Players:FindFirstChild(hit.Parent.Name) then
        Play = game.Players[hit.Parent.Name]
        if Play:FindFirstChild("PlayerGui") 
            and not Play.PlayerGui:FindFirstChild(GUI.Name) then
            GUI:Clone().Parent = Play.PlayerGui
            wait(5)
            -- Checks if the gui exists and removes it if it does
            if Play.PlayerGui:FindFirstChild("TryAgain") then
                Play.PlayerGui.TryAgain:Destroy()
            end
        end
    end
end)
0
Alright I'll try it hopefully it works duckyo01 120 — 9y
Ad

Answer this question