I'm trying to create a table for each player that enters that can be accessed by both the server and the client. I have already looked into ModuleScripts, and I am almost certain that they wouldn't work. So how would I do this?
When you create a new module
script, you should notice the default code placed is along the lines of:
local module = {} return module
This means that module scripts by DEFAULT return arrays if you keep it as it is. Module scripts WILL work for this. You may commonly see people using module scripts for functions, but be aware that many people actually store the functions IN THE ARRAY.
Only ReplicatedStorage
and ReplicatedFirst
will replicate any edits made to the array to both the server and the Client.
So lets try making a module script that returns an array with specific values:
local module = {"Digital","Veer"} return module
Now lets access it from a local-script and server-script:
local mod = require(game.ReplicatedStorage["ModuleScript"]) print(mod[1])
local mod = require(game.ReplicatedStorage["ModuleScript"]) print(mod[2])
Your output should be:
DigitalVeer