Putting a lot of modules into starter gui - good or bad?

In my game I’ve decided to put all modules somehow related to ui inside the start gui (under a screen gui).

looking something like this:

Should I avoid that due to performance reasons or does that not make a difference at all because it’s the same thing with starter player scripts and stuff?

It doesn’t really hurt performance noticeably. ModuleScripts are super lightweight, they don’t run by sitting in StarterGui; they only run when required by (require(Module))

When you put stuff in StarterGui it clones it to the PlayerGui. If you are really concerned about performance, instead of putting scripts inside your ui’s, put them inside StarterPlayerScripts, and reference your ui’s from there.

Most of them get required by this input local script they’re under because they have to catch events

What difference does that make though?

An example where putting your scripts in StarterPlayerScripts instead of StarterGui is better, is every single time your player resets, it would have to clone the Ui’s and the scripts into your player gui. I believe it is better practice to only have Ui’s inside player gui and leave StarterPlayerScripts to handle the code for the Ui’s.

Edit:
I believe putting your scripts inside StarterPlayerScript only clones it once. Which is better than leaving your scripts in StarterGui where it has to clone the Ui’s including the scripts every single time.

Genuinely negligible (if any!) performance hits.

In this particular situation, all that matters is your preference. Is it convienient for you? If not, then move them somewhere else. If yes, then keep going.

Realistically, worrying about these cases is a waste of time in terms of considering performance. Instead, you could spend your time on things that actually make a noticable difference (like parallel lua, caching exessive work, etc.)

1 Like

Thanks! Even if all modules are required and running?

It’s no difference compared to having all the code in the module run in a single localscript/script.

Sure, the initial require() is going to be slower than having the functions and stuff already in the script, but that’s when you join. Who cares if it’s ever so slightly slower then? We care about performance in-game!

2 Likes

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