Force Script to Re-Compile?


I am currently working on creating a module, the contents of which doesn’t matter. When I create an object in that module I was experimenting with the __tostring metamethod. To do this, I was writing a function like so:

self.__tostring = (function(self)
		return "Hi"

I did this to test and see if it would even work. Of course, it did. In the command bar I ran a command like this:


In doing so, I would get an output like this:

10:21:13.550 Hi - Edit

After I saw that that worked, I moved on to having it return object-specific information, so I changed the script:

self.__tostring = (function(self)
		return self.Name

When I ran the same command as above I got the same output:

10:23:38.317 Hi - Edit

This leads me to believe that the command bar isn’t using the newest version of the script. My question then, is how do I get the script to “re-compile” so that the command bar is executing using the newest version of a script (Without closing and re-opening the place)?

Things I have tried:

  • Wait a few seconds
  • Run the game
  • re-type the command

Thanks in advance!

1 Like

I’ve asked about this in the past with no luck:

There are some solutions in there with drawbacks. The easiest way is to clone your ModuleScript before requireing it, e.g.:


But, to really make my life better, I just stopped using the command bar. I switched to HotSwap when I’m writing plugin code. The only caveat is when you press the run button, your scripts will also run, so you have to make it a point to disable stuff in your workspace.

1 Like

Yes as @blobbyblob said the best and easiest solution in my opinion is modules!

You can just have a module like so:

local Module = {}

function Module.Run()
--// Code

return Module

and just re-run that every time you want to use the code inside it aka recompile

1 Like

I’ve encountered this issue before (requiring a ModuleScript from the command bar and it returning the same value, moreover table reference even when I’ve explicitly changed the table’s contents), from my experience renaming the ModuleScript and/or deleting it and recreating it with the new content seemed to work.

There’s actually a dedicated button for it up in the top right corner of the script menu, in the actions section:
Pressing “Reload Script” should cause it to reflect its changes everywhere else.


I believe it would be something along the lines of the following;

local moduleCompileFunction =, "f")
local module = {}

module.reCompile = function()
  return moduleCompileFunction()

return module

Thank you, this is exactly what I was looking for. I knew there had to be a dedicated button or command to do this. I just didn’t know what.