Over the past few months, I have been seeing few projects and guides on social media that while they teach how to make a system for GUIs, they use Folders.
It was my first time seeing this and working fine. I decided to take some research on the forum to see if anyone has to say if it is profitable and it is a good strategy, but I incredibly couldn’t, except for someone in the same reaction as I surprised:
Although not being efficient, I decided to create this topic to know if any reader knows if it is a good idea to store folders in StarterGui, if it is profitable, and specially how it can affect in scripting.
It isn’t a good idea to put your ScreenGuis in folders because they aren’t meant to go inside of folders, which is especially true when you factor in the unexpected behaviour of your ScreenGuis resetting on respawn. If you need the organization factor that folders offer, and you don’t want your GUIs to reset, you need to nest your ScreenGuis inside of other LayerCollectors. You can, however, put your UI elements inside of folders inside of the ScreenGui. It is just that folders should not be the topmost instance inside of a PlayerGui.
Okay… Now this got me confused… @XXXTMS says it is useful whenever it comes to organizing your GUIs in StarterGui and you contradicting stating that they aren’t meant to be stored in folders… I am totally confused now.
There is obviously difference in opinion but it’s really up to you to gauge whether the pros are worth it or not.
Some factors to acknowledge:
Folders have less properties and thus should take less memory than entire ScreenGuis (usually negligible but it is a memory difference nonetheless)
ScreenGuis inside of folders will reset on spawn regardless of their ResetOnSpawn property as mentioned above
You can get expected behaviour if you put your UI elements (frames, ImageLabels etc) inside of folders which are inside of your ScreenGui
There is still the option of parenting LayerCollectors to other LayerCollectors for categorization in place of folders to get the behaviour of respecting ResetOnSpawn.
According to the factors you have mention, if I were to use LayerCollector that contains Folders (or the contrary) with ScreenGui inside, would that take less memory and would be a optimization for a Roblox project?
Furthermore, it is my first time hearing about the LayerCollector | Documentation - Roblox Creator Hub… I have never heard of it in the Documentation or in simple guides that exist around the media. So, I might be asking something pretty odd here …
Do you mean LayerCollector > Folder > LayerCollector? (ScreenGuis, SurfaceGuis, BillboardGuis, AdGuis, and probably more inherit LayerCollector).
If so, that would actually be more memory intensive than just doing Folder > LayerCollector or LayerCollector > LayerCollector but if you use the former, you’d still run into the unexpected behaviour of the UI resetting on spawn regardless of the ResetOnSpawn property.
In either case unless you’re doing this hundreds or thousands of times, the memory impact should be negligible.
I was thinking this at first: LayerCollector > Folder > UI elements as well as Folder > LayerCollector > UI elements, but as reading your comment, yikes, it seems that both of these strategies are not good and can behave differently from what I can expect…
I see, LayerCollector > Folder > UI elements is fine - you would get expected behaviour. The main issue (UIs resetting on spawn) arise only when LayerCollectors are not parented to other LayerCollectors as a descendant of the PlayerGui.
So, LayerCollectors > LayerCollectors > Folder > UI elements (with/without containing ScreenGui) would behave normally and somewhat fix the issue with UIs resetting on the spawn, right? Please correct me if I am wrong…
LayerCollector > LayerCollector > Folder > GuiObject (Frames, ImageLabels, Buttons, etc) is ok
LayerCollector > LayerCollector > Folder > LayerCollector is not ok, you will run into the issue of UIs resetting on spawn.