I have been playing around with modules lately and realized that if you modify index’s in one script’s reference to the module, it syncs with every other reference.
So a few question are:
If I have a:
local Variable = {}
would that be the same in all references to the module?
What are the limitations in the sync between references?
Here’s another thread of the same topic that I’ve previously answered:
Modules return the same instance on require across each environment; if you change a member then you’re directly mutating the table that’s returned by the module if you return a table hence why every other script of the same environment will also see the change.
Correct. The client and the server both possess their own instance of the ModuleScript that’s shared across the same environment. This is also applicable to requires within ModuleScripts as the generated copy/cached version inherits the environment of the script that called it.
The command bar runs on a separate VM so it also gets independent server/client copies.