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