Module script not referencable

I have a LocalScript in the StarterCharacterScripts folder, and as a child of that LocalScript I just made a ModuleScript, to keep things organised.
But when I try to reference it with this code:

local ModuleExample = require(script.ModuleExample)

I get an error that it is not a child of the script, while it is. In the script editor it even autofils it for me when trying to reference it.

So does anyone know why I am getting this error? Thanks!

try putting those two scripts on a new baseplate game and check if it still happens

I tried it and the exact same thing happens.

The ModuleScript might not be loading quick enough. Use WaitForChild()

local ModuleExample = require(script:WaitForChild("ModuleExample"))

1 Like

That works, thanks!
However, it’s a little weird that it wasn’t working before, because from what I’ve read before, all childs of a script should be loaded at the same time as the script. But maybe this is only in ServerScriptStorage

Somewhere I read that the parent loading does not guarantee that all of its childs are loaded. Please make sure to mark as solution:slight_smile:

1 Like

Roblox made changes recently to load order