How can I do this with my folder toggle LocalScript?

Hey, Cookie Tech!

I’ve recently been working really hard on my panel project, Admino. So far, I’ve been focusing on some minor scripting and revamping the UI design, but I came across some unfinished scripts that I need help with.


Essentially, in my panel, all the UI components for each of the sidebar categories is placed in a folder under a “MainUI,” as shown below;

exp_img

As you can imagine, within each of these folders, there are a lot of UI elements, such as these folders shown below (It’ll make sense with my scripting query soon).

expanded_img


Now, there obviously needs to be a sidebar button to make the contents of each folder become visible - and invisible - whenever the button is clicked. Under StarterGui > MainUI > SidebarFrame, I have all the sidebar buttons, such as the examples below (the layout in the “Explorer” tab as well as the actual sidebar appearance on the Admino panel project itself).

btn_img


So, as you can see, every single sidebar button has a script called “BtnLS” (LS stands for LocalScript). For example, in “CmdsBtn,” this is the code I have;

local folder = script.Parent.Parent.Parent.MainFrame.CmdsContents
local button = script.Parent
local sound = script.Parent.BtnSound

button.MouseButton1Down:Connect(function() --When button is pressed ...

-- ...then make these two elements within the folder visible, or invisible.
folder.CommandTypesSidebarFrame.Visible = not folder.CommandTypesSidebarFrame.Visible

folder.ModerationList = not folder.ModerationList.Visible

sound.Playing = true

Of course, this script works perfectly fine, but there is an issue you might’ve already caught onto … :scroll:

These local scripts - within each of the sidebar buttons - will toggle the visibility of their respective folders (under the same name as the button, of course).

However, this means that whenever I click a button for a folder’s contents to become visible, whichever folder contents are already visible will be overlapped, resulting in - well, annoying overlaps.

I haven’t currently found a good solution for this issue, which is why I hope someone here on Cookie Tech will be able to offer some suggestions or assistance with changing up the BtnLS script a bit.

Thank you, and I hope this made sense! :smile:

ICONS DISCLAIMER

All the icons used in the Admino panel, such as the ones shown in the sidebar, are belongings of Flaticon and all credit for the icons (filled and 3D) goes to them.

You COULD run a for loop over all of the frames first and make them all invisible BEFORE making the selected frame visible. That’s what I do for my panel.

Hm, interesting. I could have a seperate script in each of those folders (for example, CmdsContents) which will toggle the folder content’s visibility upon a trigger of some sort (such as a button press on HomeBtn).

But if I were to do script that, I’m not exactly sure what kind of trigger the script would look for … the user could be pressing any button (eg. CmdsContents contents are visible, user pressed a sidebar button, then how would the script know which button’s press to look for? Will it have to forever check for all of them?)

Id do a for loop with GetDescendants on the sidebar in the case of your buttons, then do object:IsA(“TextButton”), then if its clicked, do another for loop for all the FRAMES and make them invisible, then proceed after the loop is done to make the target frame visible.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.