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

I want to toggle a GUI off and/or on, but why won't it?

4 answers

Visible isn't ScreenGui property. Use Enabled instead.

local GUI = game.StarterGui.GUI

GUI.Enabled = false -- GUI is disabled which means player can't see it

3 comments

0

Oh yeah i compleatly forgot about that, but i wanted to do just ONE screen, or should i use a frame instead?

0

but say i want just that TextLabel to go away and not the others.

0

oh In that case you should use TextLabel.Visible = false :)

local GUI = game.StarterGui.GUI -- Wont change anything for the player. Use game.Players.LocalPlayer.PlayerGui.GUI is the gui.

GUI.Visible = true -- wont change anything will even error as visible isn't a property of a GUI, thats called "Enabled"

game.Players.LocalPlayer.PlayerGui.GUI.Enabled = true

would do what you need.

Make sure you put 2 frames in the one screengui and in one of the frames put a button (text or image) then try:

local frame = script.Parent.Parent.Parent:WaitForChild('name_of_your_frame')
script.Parent.MouseButton1Click:connect(function()
	frame.Visible = not frame.Visible -- since Visible is a boolean, it can be toggled by doing the opposite of what it is so if its open its true vice versa
end)

You can either write it as ...

local GUI = game.StarterGui.GUI

GUI.Enabled = false -- it disables the "ScreenGui" and makes it invisible along with it's properties

or you can write it as...

local GUI = game.StarterGui.GUI

GUI.Frame.Visible= false --add a Frame/Textlabel/imagelabel/ etc.

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