How do i make a module script for each player

I want to know if i can access a module script in a local script so that each player has his/her own copy. I want to do that because i want to store data across two different scripts, how do i do that. I don’t really understand how module scripts work.

If I understand what you are asking, I believe you can accomplish this. A module will store whatever information you give to it, but only for that particular client if you are using LocalScripts. Using this method, you could access the module’s information from 2 LocalScripts at a time.
For example,

--LocalScript 1
module = require(game.ReplicatedStorage.ModuleScript)
module.x = 20
--LocalScript 2
module = require(game.ReplicatedStorage.ModuleScript)
wait(2)
print(module.x) --Outputs 20

Ask away if you have any questions… or if I misunderstood your question. Also, please note this will only work if you return a table in the module.

1 Like

ok thank you this is what i was asking for, i’ll check if it works. Also is module scripts the best way to store data between scripts or just storing data in general?

No problem! If you can, try to store information in one script. I haven’t asked others what they believe the best practice is, but storing information in a module can be extremely useful. Another way of bridging data could be done through objects such as StringValue, etc. Keep in mind it could be difficult to manage… but it is certainly possible and has worked extremely well for me in the past! Modules are also great to store functions.

1 Like