Pointers to tables returned by ModuleScripts in game world and command bar in Test Server are different

If I have a ModuleScript (ModuleA) which returns a table, it will return a pointer to that table. This means that if I have multiple scripts on the server (ScriptA, ScriptB, ScriptC etc.) which all require ModuleA, the pointers will all be the same, e.g. table: 101B56F0. So if I edit a value in the returned table in ScriptA, then the table will also change for ScriptB and ScriptC if they also required ModuleA (because the pointers all point to the same table).

Now, if I start a Test Server and require ModuleA, the pointer is suddenly different from the pointers returned by the Scripts: e.g. table: 11067C98. This shouldn’t be the case. If I require ModuleA through the command bar in the Test Server it should return a pointer to the same table instead (table: 101B56F0). It seems that right now the game world and the command bar in a Test Server are treated as different environments. This is really unfortunate because it makes testing and debugging harder if the testing process includes editing tables returned by ModuleScripts.

For the game I’m working on I have a ModuleScript which saves data for every player. If I want to give one of the test players extra currency I cannot use the command bar in a Test Server because of this behavior. Using the console in an online server does work correctly though which makes me believe this is a bug with the command bar.


This is a security thing. Different security contexts (e.g. command bar, scripts, plugins) each run in their own separate environments, to keep them isolated.

Whenever a ModuleScript is required for the first time, it will run in the context of the requiring script. As a side effect, ModuleScripts can run multiple times, once for each context.

If you want to use the command bar, you’ll have to pass data through a Bindable or Remote.