ModuleScripts run twice when they are not published

  • Describe the bug. Describe what is happening when the bug occurs. Describe what you would normally expect to occur.

When in Studio, if you require a ModuleScript that is not published to Roblox and is instead in the game somewhere, it will run twice.

After publishing and replacing the require() with the ID, it runs normally.

  • How often does the bug happen (Everytime/sometimes/rarely)? What are the steps that reproduce the bug? Please list them in very high detail. Provide simple example places that exhibit the bug and provide description of what you believe should be the behavior.

This is currently happening every time I require a ModuleScript that is not published to Roblox.

  • Where does the bug happen (www, gametest, etc) Is it level-specific? Is it game specific? Please post a link to the place that exhibits the issue.

This is happening on the latest version of studio and is happening with multiple ModuleScripts (has been an issue between me and multiple other people).

  • Would a screenshot or video help describe it to someone? If so, post one.

Catalog items appearing more than once in the GUI, loaded via ModuleScript
image

  • When did the bug start happening? If we can tie it to a specific release that helps us figure out what we broke.

I first found this bug about 10 minutes ago. It was not happening prior to this build (as far as I know)

  • Anything else that you would want to know about the bug if it were your job to find and fix it.

Nope!

1 Like

Can you please provide a repro? When I create a module script like this:

local module = {}
print("loading...")
return module

and then require it like this:

require(workspace.ModuleScript)
wait()
require(workspace.ModuleScript)

I only see “loading…” printed to the console a single time. Is it possible you are requiring a clone or copy of a module script? ModuleScripts will be run a separate time for each clone/copy that you require, even if the source code is the same.

2 Likes

This is very likely not a bug, and just an issue in your code. It’s important to attempt to reproduce a bug with the least amount of noise possible, so you can be sure it really exists.

Keep in mind a module required by both the client & server will appear as if it’s running “twice” in accurate play solo (because it is)