i have a module with a table, when i tell the server side to print it it prints this:
but when the client prints it eveything is at 0:
can clients just not access module or something?
i have a module with a table, when i tell the server side to print it it prints this:
but when the client prints it eveything is at 0:
can clients just not access module or something?
The contents of ModuleScripts arenât editable by any script during runtime. When a script uses require
on the module, that script has its own âcopyâ of the module so if you require
the script and then the client prints the module, the client and the server are looking at their own copies.
if i re-require the module each time i wanan check it on client side, would that work?
You still wouldnât have the same data the server has. If you re-require the module each time, it could lead to performance issues and youâd just have a bunch of copies of the module.
If youâre wanting to send the data from the server to the client, use a RemoteEvent.
Hate to break it to you, but thatâs not how Module Scripts work.
The first time it is required is when it runs the script. Every require after that returns the same instance from the first require. Itâs why you canât have two returns because it is only run once and has to return the same output.
Okay, I did recheck everything and you are correct. Thatâs my mistake. The module can be âeditedâ but only in the same Lua environment e.g. server, client, command bar. And in the case of OPâs issue, they will still need to use a RemoteEvent as the data changed on the server will not replicate over to clients.