Is it a bad practice to have one LocalScript that controls the whole GUI system?

I’m thinking of creating one LocalScript that controls everything in GUI (Tweening, Buying Gamepasses and DevProducts, Sound Effects, Visual Effects, etc)

Is it a bad practice? Or should I have multiple LocalScripts?

What are the pros and cons of doing so?

A single large script is fine, but you need to structure it well, so as the script grows it’s still really easy to change it.

1 Like

As a system software engineer, my answer to having everything in one script is that it’s bad practice for personal projects and in industry. In fact, major programming projects in other languages (C/C++ comes to mind) have different functionality broken into different files. For example, the Linux kernel has a gazillion files (well over 100,00 files). CLang/LLVM and GCC both have lots of files as well. Given the way that LUA works, you really should break one large script into a bunch of smaller ones. You can have one LocalScript and then parent a bunch of ModuleScript instances to it, then include them in the LocalScript. That would be the proper way to do it.

For having different modules:


  • Easier to understand and maintain.
  • Easier to find the functionality if the logic is broken down into one functional group per module script.
  • Enhances modularity and code reuse.
  • Just makes better sense.
  • Easier to have multiple people working on different files.


  • More files.
  • Complex interaction issues if modules reference each other (not allowed in LUA).

For having everything in one file,


  • Possible to do forward declarations for circular function references.
  • Everything is in one place so you don’t have to hunt through multiple files to find what you are looking for.


  • Harder to near impossible to maintain.
  • Lends to the problem of spaghetti code.
  • All scripts have a finite size limit of about 200,000 characters or so.
  • Ordering of function declarations matter a lot.
  • Everything is in one place which makes finding the code you’re looking for harder.
  • Harder to modularize and refactor if needed.
  • Impossible to use Object Oriented Programming since you have to use module scripts to define classes with table metamethods and such.
  • Impossible to have multiple people working on the same file without stepping on each other.

That’s about all that I can think of off the top of my head.

NOTE: I’m not going to say anything, but this topic should probably be in the scripting support forum instead of the art design forum.