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

How do i make a Dissapearing Gui?

Asked by 9 years ago

I'm trying to have a script what makes the frame disappear when the button is clicked but it doesn't work. It doesn't work

11 do button.MouseButton1Click:connect(function()
22   frame.Visible = not frame.Visible
33 end

when I press the button the frame just stay there.

Thanks but it says button and frame are unknown.

3 answers

Log in to vote
1
Answered by 9 years ago

Use the code blocks for code, and don't bother doing the line numbers. the code block does it for you.

Answer:

All Gui objects (except the Guis themselves) have a bool property called Visible. So:

1button.MouseButton1Down:connect(function()
2    frame.Visible = false
3end) -- also, these types of functions have a ')' after the end

Also, you need to define everything (like the button) that you will use in the script.

Ad
Log in to vote
-1
Answered by 9 years ago

Answer : The button and the frame are not defined so

1button = script.Parent --Make sure that the script is in the button
2frame = script.Parent.Parent.FrameName --Replace the name of the frame here
3button.MouseButton1Click:connect(function()
4frame.Visible = false
5end

If you would like it to reappear when they click it again, then

1button = script.Parent
2frame = script.Parent.Parent.FrameName -- Replace the name of the frame here
3function onClicked()
4if frame.Visible == true then
5    frame.Visible = false
6else
7    frame.Visible = true
8end
9button.MouseButton1Click:connect(onClicked)

It's as easy as that

Log in to vote
-1
Answered by 9 years ago

Here:

1local b=script.Parent
2local fr=script.Parent.Parent.Frame -- Replace Frame with the Frame's name
3b.MouseButton1Down:connect(function()
4    fr.Visible=not fr.Visible
5end)

Answer this question