I’ve been struggling to find a solution to effiiciently toggle visibility of UI frames in a single script, and I was hoping someone has a solution to this problem.
Here’s an example — for my Admino panel, let’s say there is a Dashboard frame, a Messages frame, and a Moderation frame. When the user selects the “dashboard” button, thus making the “dashboard” frame visible, all other UI frames must be made invisibile through the “Frame.Visible=false” function.
However, there are two ways I can do this — I can either define the “messages” and “moderation” frame through the local function and then lay them out over two lines of a script. Or, if possible, I was wondering if I can do this all at once in a single line of a single script.
As you know a panel contains many, many frames, listing them out line-by-line is simply not an option. I have well over 30 frames and counting as I modify them and attempt to reduce this number but I need an efficient way to toggle visibility without hogging 30 lines of a script.
So I tried putting this into a LocalScript within ServerScriptService, before I actually ran the script I got a lot of red underlines …
local x = game.StarterGui.MainUI.MainFrame
local y = game.StarterGui.MainUI.MessagesFrame
local z = game.StarterGui.MainUI.ModerationFrame
if x: y = z = false
elif y: x = z = false
elif z: x = y = false
end