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

What is a line to make a gui appear? [closed]

Asked by 10 years ago

I am making a gui book for a group. I made five textbuttons, and I already made a close button that closes. But how do I make another that can make it appear?

Close button's script:

1print("Close button loaded")
2 
3window = script.Parent.Parent
4 
5function onClicked(GUI)
6    window:remove()
7end
8script.Parent.MouseButton1Click:connect(onClicked)

And I also need a open button script that can make gui appear.

Locked by User#19524

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

1 answer

Log in to vote
0
Answered by
Ryzox 220 Moderation Voter
10 years ago

Instead of using :remove() or :Destroy() I would recommend using the Visible property which is present in Frames, TextLables etc

Assuming "window" is a Frame and not a ScreenGui I would do this:

1print("Close button loaded")
2 
3window = script.Parent.Parent
4 
5function onClicked(GUI)
6    window.Visible = false
7end
8script.Parent.MouseButton1Click:connect(onClicked)

Where it says "window.Visible = false" you can change to true and it will become visible again.

Now assuming that this is a ScreenGui and you want to use :remove() I suggest keeping a copy of the ScreenGui in Workspace and using :Clone() and parenting it into the players PlayerGui when you need it to be re-opened.

1print("Open button loaded")
2 
3window = workspace.ScreenGui:clone()
4 
5function onClicked(GUI)
6    window.Parent = Player.PlayerGui --assuming you already have Player declared
7end
8script.Parent.MouseButton1Click:connect(onClicked)
0
..? This doesn't answer his question at all. His question had nothing to do with the script he included. AmericanStripes 610 — 10y
0
Sorry, I didn't read it properly, I edited it, hopefully it makes more sense now. Ryzox 220 — 10y
0
If it needs to toggle on/off, you can just add the line 'window.Visible = not window.Visible' (assuming window is a TextButton). This works because since 'not' reverses a boolean value, the gui's Visible property becomes whatever it currently doesn't equal. Perci1 4988 — 10y
0
Yeah, i want it to open/close a whole gui using only button, i hope this helps. CowardlyArnold 20 — 10y
Ad