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

How would I make A Gui Dissapear After clicking it?

Asked by 9 years ago

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

Log in to vote
1
Answered by 9 years ago

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
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! ILikepie2100 20 — 9y
0
You are welcome! :) Darknesschaos 0 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

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.

Answer this question