Hello! I am starting to get into programming and noticed that a few developers I work with use a module based game. I was wondering what the pros and cons of setting up your game this way. By module based game, I mean all scripts (except a ServerScript and a LocalScript) are ModuleScripts, and are initialized when the game loads.
Is a module based game better in some ways, or is it just user preferences?
If you use a module based game, what made you choose modules over ServerScripts and LocalScripts, are modules easier for you?
Should I start learning how to set up a module based game, or continue using what is easier for me?
If you are wondering the same thing I am and have any questions, reply with them and I will link them here!
When programming there is not necessarily a good and bad way to do something, they are just different ways to get to the same result. Use what feels right to you and what seems the least complicated or easiest to use. Good luck on your programming journey .
The following answers are my own opinion and mostly subjective:
Although having a module-centered game comes down to user preferences, I believe that module-based games are better.
a. If something throws an error, it won’t break the entire script/system if it were to be running on a single script, rather than multiple modules.
b. Debugging and management is easier with multiple modules; this is especially helpful when when your scripts begin to exceed the thousands of lines.
c. Your modules can sometimes become recyclable to be reused in later projects.
I chose modules over serverscripts for the above ^ reasons. I use one Script on the server and one LocalScript on the client, and everything else is managed by a series of serverside and clientside modules.
In the end, it’s up to you to do what you want in the ways & methods that you’re comfortable with. Do what’s easy for you.
Modular programming has a lot of benefits, and almost no serious drawbacks.
By breaking your game / software application up into modules, it becomes very easy to reason about specific parts of the application without worrying what other parts of the application are doing. Modular programming allows you to follow the SOC (separation of concerns) and SR (single responsibility) principles in software engineering. A single module does one thing, and does it well. Your “team” class module shouldn’t care about what your inventory UI module is doing, and vice versa.
It also makes your game extensible, maintainable, scaleable, portable, and most importantly - easy to understand. If I hop into a game project that consists entirely of modules that follow the SOC principle - I can very easily make big updates to the game and quickly learn the game’s systems. Whereas if I were to hop into a game project where everything was just tied together through a bunch of arbitrary scripts, it becomes very hard to understand what’s going on, and making updates is not as straightforward since one change could break unrelated game systems.
For more information on modular programming, you can visit these resources here: