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

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

Asked by 8 years ago

I want to toggle a GUI on and/or off, but it wont turn on or off! I would know how to do it if it just was

local GUI = game.StarterGui.GUI

GUI.Visible = true

I tried it, and it doesn't work! Can someone plz tell me why?

4 answers

Log in to vote
1
Answered by 8 years ago

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
0
Oh yeah i compleatly forgot about that, but i wanted to do just ONE screen, or should i use a frame instead? Chez_Guy 67 — 8y
0
but say i want just that TextLabel to go away and not the others. Chez_Guy 67 — 8y
0
oh In that case you should use TextLabel.Visible = false :) personal_ly 151 — 8y
Ad
Log in to vote
0
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
8 years ago

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.

Log in to vote
0
Answered by 8 years ago

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)
Log in to vote
0
Answered by 8 years ago

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.

Answer this question