Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can I close a screengui?

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.

2 comments

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"

0

Just make what ever you want Visible = false. That would make it visible or invisible, hence the name..

2 answers

✓ Accepted answer

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.

2 comments

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.

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.

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.