No 1.
So I’m using trying to use a modular structure for a game I’m going to work on but how would you know when to use different modules for different things? Also, where would you put them?
No 2.
Lets assume for example, you want to make a gun module. How would you handle that?
If anyone can answer 1 and 2 it would be very appreciated.
Q1:
You should use modules for repeated functions/methods, or basically store arrays of values inside a script that is accessible by the targeted environment.
You should put the module inside ReplicatedStorage ONLY IF you want it to be public, since exploiters may be able to view it. Q2:
You can make stats inside the module, for example an identifier; module._weapon_id = "my_weapon"
or otherwise basic stats such as; module._base_damage = 65
therefore, these values will be returned when you use the require() method,
giving you easy access to these stats.
Q1
Fair enough but then how would you structure it? I’m assuming a script in serverscriptservice then a local script in starterplayer. But what about handling ui? Or whenever the character respawns. Or am I just over thinking it and 2 single scripts are the way to go.
Q2
So going back to the gun module, should I be creating the module for the main functionality of the gun then creating a damage module, gun data, etc?
Also also, you say modules should only be used for one time things but what if I have a scenario where I’m only using it once? Main reason would be to keep the architecture but I feel like something is wrong with that.
As I said, things such as stats should be stored inside Server Storage instead of Replicated Storage. Unlike Replicated Storage, Server Storage does not replicate to the client, therefore, you don’t have to worry about security.
*Note that you can only access modules inside Server Storage with server scripts.