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

How can I close a screengui?

Asked by 8 years ago

Like when people click to open a gui how do I make like a textbutton to close the gui so it doesn't have to stay open and stay on the screen forever.

0
This isn't a site for requests, but just make a button that makes the frame's visibility false, and when you click it have it so the button changes. Simple, really, could literally just find a model with the name "Click to close gui" k1nq 30 — 8y
0
Just make what ever you want Visible = false. That would make it visible or invisible, hence the name.. yougottols1 420 — 8y

2 answers

Log in to vote
-2
Answered by 8 years ago
Edited 8 years ago

Put this is StarterGui

local gui = Instance.new("ScreenGui",game.Players.LocalPlayer.PlayerGui)
local button = Instance.New("TextButton",gui)
local frame = Instance.new("Frame", gui)
button.Size = UDim2.new(0,50,0,20)
button.Text = "Open"
frame.Size = UDim2.new(.5,0,.5,0)
frame.Position = UDim2.new(.25,0,.25,0)
frame.Visible = false
button.MouseButton1Down:connect(function()
if frame.Visible == false then
frame.Visible = true
else
frame.Visible = false
end)

It doesn't look very fancy but It is what you asked for.

Also next time please give an example script.

0
This type of answer is frowned upon by the SH community. Scripting Helpers is not a request site. It's a site where new scripters come to learn. Giving a person a complete script teaches nothing. Your answer is not constructive and does not explain what is actually happening. AZDev 590 — 8y
0
On top of not being constructive, your code is not tabbed. This doesn't cause much of a problem in smaller scripts but when scripts begin to grow they become harder and harder to maintain when they are not tabbed. Not tabbing your code is a poor exercise to practice when programming. AZDev 590 — 8y
Ad
Log in to vote
1
Answered by
AZDev 590 Moderation Voter
8 years ago

Scripting helpers isn't a request site but here are a few things that will hopefully set you looking in the right direction.

You're gui should have a frame in it. Frames have a property called visible.

One way to do this is to set that property to false.

A better way to do this is to use the tween method and tween the gui off the screen.

For more information on Tween click here.

Answer this question