No, your game wouldn’t run any better, in fact don’t quote me on this, it might be possible that your code runs slightly worse to the most MINISCULE degree since.
The reason and logic behind making your code more modular down to 3 main categories:
Abstraction
When you’re writing code, it’s hard for people to make any necessary edits to the code, and especially with variables and other things, it becomes hard to see what’s doing what.
With modules, it’s much easier to create getter and setter functions that are labeled precisely to what they are intended to do.
Also it makes the use of utilities so much easier.
Searching
When you are searching for a specific function or something of that nature when working with a 2000 line script, it is very inefficient (You probably noticed by now).
By using modules, you can easily separate big chunks of code, and have a much easier time finding and editing something in your code that meant to be changed.
Now don’t fall into the trap of creating a new module for every single block of code, b/c that makes it difficult to find certain modules, defeating the whole purpose altogether.
Functionality/Expandability
When working with modules, it is so much easier and you’re so much more inclined to make reusable blocks of code.
Imagine every time a round in your game ended, you wanted a on-screen effect to play. Normally, you would have create code that would track whenever a round ended, then create the effect, then play it whenever the round ended.
Instead with re-usable modules, imagine if you already had a function that tracked when a round ended. Even better, what if it allowed you to attach a new function to play every time a round ended.
Now you’ve gotten rid of half the work. Any time you want something new to happen when the round ended, you just have to create the function, and attach it.
Obviously that’s a low-scale example, but that’s the type of stuff that you could do, thus making it easier to expand and update games over time.
Now finally, don’t fall into the trap of just using modules b/c they are the norm. Whether your game is client-sided or not doesn’t specifically invoke the use of a modular system, but it’s still recommended none the less.
But for a method of organizing the game, here’s the structure that I use:
-
Init modules and server running modules in ServerScriptService
-
General server functions and server utils in ServerStorage
-
Client init modules and client running modules in StarterPlayerScripts
-
General GUI module functions in StarterGUI
-
General utils (both client and server) in ReplicatedStorage
-
Server Init Script in ServerScriptService
-
Client Init Local Script in StarterPlayerScripts
-
Dedicated character local script + character module functions in StarterCharacterScripts
-
Local Script in ReplicatedFirst