What Are the Pros and Cons of a Module Based Game?

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.


Questions

  1. Is a module based game better in some ways, or is it just user preferences?

  2. If you use a module based game, what made you choose modules over ServerScripts and LocalScripts, are modules easier for you?

  3. 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!

Community Resources

Well it depends on what type of game you are making, If its a round-Based game I suggest using Modules for the core of the round system.

Modules can be accessed from anywhere and you can return functions using them.

Its up to you, Modules aren’t hard. If you watch @Alvin_Blox U will find a tutorial on modules. Its really not hard to be honest.

I hope this helped you :smiley:

2 Likes

To add onto this, I would also check out this article on Object Orientated Programming (or OOP for short) if you plan on utilizing module scripts:

(All about Object Oriented Programming)

1 Like

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 :slightly_smiling_face:.

2 Likes

The following answers are my own opinion and mostly subjective:

  1. 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.
  2. 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.
  3. 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.
2 Likes
2 Likes

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:

https://education.roblox.com/en-us/resources/intro-to-module-scripts

Also related : Microservices

3 Likes