I’ve been learning a bit about single script architecture and how it is used in a lot of big games. I’m the type of person who will usually just make multiple scripts for each tool, modifying it so the tool behaves differently. How would single script architecture be constructed? So far, all I know is that you use 1 script for the server, and 1 script for the client and from there you can continue with module scripts. but what would the inner of these scripts look like? would all of UserInput service be mashed up into 1 UserInput service like this:
local UserInputService = game:GetService("UserInputService")
if input.KeyCode == enum.KeyCode.E then
-- do stuff here
if input.KeyCode == enum.KeyCode.F then
-- do stuff here
-- and so on
Ive searched for a while and i couldnt really find anything on how the scripts are constructed using single script architecture; just the idea of it. could anyone provide a example of this being used?
Also a few more questions I have are:
how are tools constructed with this? is there a module script that requires a module script that eventually requires the module script that has the function of how the tool should work?
is this better than using multiple scripts for really large games?
what are the pros and cons of doing this?
how can i transform my game (which has many scripts) to follow this architecture?
Tbh I feel like a single script (for complex games, simple games this would be fine) is not efficient
If your game has multiple systems like shooting, interacting with npc’s and buying equipment, having it all in one script could get quite messy
But there are times when this could be useful like rn I making a rts game and my server side has many scripts but my client side is 1 local script since most of the logic is handled by the server
It looks something like this:
LocalScript -- Connected to remote event for when game state changes
| |-Handle unit selection
| |- A module to give new orders to units
| |-Buy units and buildings
|-Give Game Summary
for stuff like user input and run service I just disconnect them when I am done with them
Makes the explorer look cleaner
Some times more convenient
Some times hard to find the code that does a specific function when you have lots of modules (maybe can be solved with better managed)
Management is NECESSORY, unless you wanna speed 5 min trying to find the module that does some randomly specific function, make sure your module tree is managed