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

How would I make A Gui Dissapear After clicking it?

Please Help me Would this be script be somewhat Correct?

function onClick() if game.StarterGui.ScreenGui.TextButton.Visible == true then game.StarterGui.ScreenGui.TextButton.Visible = false end end

game.StarterGui.ScreenGui.TextButton.Visible.MouseButton1Down:connect(onClick)

2 answers

✓ Accepted answer

That's one way to do it and it looks good! However, I recommend testing this on your own and see if you can come up with other ideas. :)

Another way you could have done this would be:

local textbutton = script.Parent -- since the script is located inside the Textbutton, we declare this


function onClick() 
	if textbutton.Visible then --If the TextButton exist and it's visible then...
		textbutton.Visible = false  -- We set it to false
	end 
end


textbutton.MouseButton1Down:connect(onClick) -- We connect the function

2 comments

0

Thanks so Much! I love how you even did the -- To explain the script I never understood how many script.Parent.Parent things to do now I do THANKS!

0

You are welcome! :)

The best way to know if something will work is to test it yourself. Try seeing what works with it and what does not (the print function really helps with this). Keep in mind that click events do not fire on the server if you have the FilteringEnabled property set to true on the Workspace.

Also, please use a code block when showing code. It makes it easier for people like me to see and interpret it.

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