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?
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
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.