Command bar does not update when using require()

So here is the problem. Lets say I have a module does this:

return print

It will work if I call require(game.Workspace.module)("Hi") and print… “Hi” if I run the code in the command line, I should get the same result. Now I wanna change the module to

return error

But it still prints in the output instead of erroring? I want it to error. I updated the script closed command line, and every thing.

This is a bug. I did get InCommand and kindof solve this issue - Did not work

I also get this issue.

For some reason, ModuleScripts won’t update their source when you edit them. A fix is to duplicate the ModuleScript and delete the old one. It’s very annoying.

Requiring modules loads its code onto memory, and then uses that as a reference to scripts that requires() it. This reduces load times after its initial require, especially if the modules are massive, but the consequence is that once it is loaded, it won’t update when trying to require the same module again, even with edits.

You can always run this in the command line. I’d probably reload my place after using this line many times though:

local M = Source_Module local New_M = require(M:Clone())

-- You can also keep the functions or contents of a module temporarily using _G.
local M = Source_Module local New_M = require(M:Clone()) _G.Module = New_M
1 Like

Open the ModuleScript and on the script editor ribbon tab, there should be a button named “Reload” that you can click if something else has previously require-d the script, click that to refresh the cache and when you require it again it should return the latest value

As @Y_VRN says, ModuleScripts will only run the first time you require() them and will return what they first returned afterwards. This is intended behavior.

You should require a clone of the ModuleScript to make it run afresh every time, but note that this will mean the clone’s Parent will be nil when it runs :slight_smile:


1 Like