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

How to make a Gui Exit Button?

Asked by 10 years ago

How would I make a button that closes a Gui? I have a Welcome Gui and a Button but not sure how to make the Button do something. All help is appreciated, thanks. :)

2 answers

Log in to vote
0
Answered by
Mowblow 117
10 years ago

Put this script inside of a button that is inside of a Gui Frame. The frame should also include all Gui elements such as text and images.

local button = script.Parent
local frame = button.Parent

button.MouseButton1Click:connect(function()
frame.Visible = false
end)
Ad
Log in to vote
0
Answered by
Ekkoh 635 Moderation Voter
10 years ago

What Mowblow posted would work (assuming your hierarchy was set up accordingly), but I'd save lag by just destroying the whole GUI instead of just making it invisible, unless of course you need to re-open it later.

local btn = script.Parent
local frame = btn.Parent

btn.MouseButton1Click:connect(function()
    frame:Destroy()
end)

Answer this question