Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Gui when touch remove not working?

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)

2 comments

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

0

I don't understand that

1 answer

✓ Accepted answer

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)

1 comment

0

Alright I'll try it hopefully it works

This discussion is preserved as it was. New answers, comments, and votes are closed.