I’m not sure if this is a ‘bug’ per-se, but I would call it an undesired result.
When testing my ModuleScripts in Studio, I like to execute them on the command bar using ‘require.’ However, after one usage of a ModuleScript, any other uses of the ModuleScript seem to all be the same instance of the first time it was required. Thus I cannot test changes I made to the ModuleScript unless I either test it in Solo or reopen the place in Studio.
Easy way to replicate it would be to create a ModuleScript with simple code, like:
print(2 + 2)
Then in the command bar, write:
require(foo)
Should print out 4.
Then change the ModuleScript code to:
print(2 + 4)
Again, require the module from the command bar. It will print 4 still.
If you’re working with modules and testing them: I would recommend adding a script fragment to your plugins that lets you do something like: _G.refresh(ModuleScript), which re-creates the module script, reassigns the source, and reopens it in the editor (You can do this with plugin:OpenScript( ) ).
Sadly OpenScript does not work for ModuleScripts. I posted it here as a bug a few weeks ago, but didn’t get any movement on it. But yeah, I’ll probably just add a way to refresh the source regardless.
ill probably include the fact that since command bar and original scripts run on different script context, I cannot playtest stuff with command bar and modules just because of different script context.
Why’s that matter? Because command bar and Roblox scripts are completely separated/isolated from each other. If some game script required one module, it would initialize only once and no more from other scripts, but you can initialize them TWICE if you were to require it from command bar aswell. I would really like more if these weren’t isolated from each other. At least make an option to run either as game context or plugin context.
Now that you brought up contexts, it probably is intended behavior (though not intuitive), but yeah if that is the case then having an option to choose would be nice as you said. Having to for example create admin UIs every time does not seem like an optimal solution, it’s time consuming, especially if you need to do something on the server.