Module script creating/placement

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

1 Like

:skull:
make a module, make an initializing function, then write the code boom u can use oop if u want

1 Like

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

1 Like

Something like this from client

local GunModule =require(GunModule) 

local Gun = GunModule.New(Stats:{}) 

Gun:Fire() 

Actually, you should be using them for repeated use cases. I think you misunderstood my statement.

I have a github repo on my bio if you would like to see some use cases of modules.

I’d be happy to check it out (chharsss)

Forgive me if I again am overthinking but wouldn’t it be dangerous to have stats on the client where it could be exploited?

Over thinking about safety isn’t bad but what we’ll be passing is the servers information on the gun w remote function

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.

1 Like

Alr I’ll take that advice from all of you thank you very much!

2 Likes

No problem. Good luck with your game.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.