Need help understanding how to organize game

I’ve seen a lot of people say that a good way to organize your game is by having one server script, one local script, and then everything else is modules, but I can’t wrap my head around it

  1. How would you handle GUI? I usually use one local script for each page but apparently that’s terrible so I want to learn this method to make everything easier

  2. Where in the explorer would you store the server script and the local script? Where would you put the module scripts?

If someone can give me an in depth explanation of how to organize your game using this method (or any other method that’s better) it would help me a lot, thanks. Some examples would also be helpful

People say a lot of things.

Here is a good discussion thread on the topic.

Generally you should research into software design patterns.

https://devforum.roblox.com/t/fussing-over-code-organisation-leads-me-to-be-unproductive-unmotivated-and-frustrated-is-this-something-worth-the-attention-i-give-it/758200/9?u=dthecoolest

Use the same logic as how you want your scripts to run, if you want to your script to run locally and run everytime a character spawns and you are too lazy to use player.CharacterAdded you put your script in StarterCharacterScripts.

I think you can think or research on your own for this question.

1 Like

The one server script people talk about is the main script to handle all server side interactions and initialise all modules meant for server side. The one local script is to handle client-side interactions (e.g. GUI’s) and initialise module scripts for client-side. It is absolutely necessary to put the server script in SSS and the local script goes wherever most client side interactions are happening. I’ll give you an example for both:

  • If you’re making a game where people jump from platform to platform trying not to die, you could have one script “GameEngine” in SSS to handle server side things like datastores and leaderboards
  • If you have a ton of GUI elements in your game then it is recommended to put your local script in StarterGui as it is the home of gui elements. However, StarterPlayerScripts is the most versatile location for local scripts, so prioritise based on your game
    Most people would parent the module scripts to the script that they would operate on and I agree with them as this is much more convenient.

In summary,
Organising your game requires to plan where to put your scripts so that they are best placed to handle the interactions they are built to handle. The module script will need to be placed in a location where they can be conveniently accessed by the scripts that will use them

1 Like

If you don’t know how to organize your game, try to look ahead. Look into the future code-base of your game. What features will you have? How will those features fit in your game neatly? What can you do to make sure that you can add something without breaking other features?

Personally, I use the system that Minecraft uses: One folder containing more folders, which contain ModuleScripts inside them. And there are only a few ServerScripts and LocalScripts that exist which all depend on that one folder.

1 Like

What kind of functions go in the module scripts vs the local & server scripts? I may be overthinking but I still just don’t understand how everything ties together. Say you have a menu system with a local script and some modules, what kind of things would you store inside of each script?
For something server sided, let’s use a tycoon as an example. What kind of data/functions would be in all the scripts that handle the tycoon?
This question goes to you as well @MysteryX2076 since I’m curious about how both of you would answer this

How i do it is
server scripts go in serverscript service
Local scripts go in starterplayer/character(depends)
And module scripts can go in replicatedstorage(if used by both server and client) serverscriptservice(if used by server only) and starterplayer/character(if used only by client)

1 Like

I will use your examples to explain here:
For a menu system, you would obviously have the local script to require the module script. And the module script could house functions for each button eg. play, credits etc. So module scripts that a local script will use needs to have client-sided operations like changing gui elements
For a tycoon, you could,say, one module script to handle data stores of incoming and outgoing players, and another to handle what happens when a button is hit and what to do when it happens
So module scripts being required by server scripts need to have functions and data that either the server needs to handle or ones that only the server can edit (eg. only servers can use data stores)

Ultimately the way the module scripts are framed and used depends on how well you organise. While at the least you need to require the right module scripts, you also need to have the sense of where to place these scripts that they can be best accessed by the scripts that need them.
(Once again back to the menu example) You have a lot of module scripts to handle each button. A good place to keep them is under the script requiring them or under the screen gui, a good place to store. You could also keep them in rep storage if you wish as its a popular place for module scripts

1 Like

Okay I understand a little more now thank you