April 29, 2021, 3:59pm
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!
April 29, 2021, 4:03pm
I created another place and put the scripts in the same location, it worked. Next time if this happens I will try what you said. Thanks!
try putting those two scripts on a new baseplate game and check if it still happens
April 29, 2021, 4:14pm
I tried it and the exact same thing happens.
The ModuleScript might not be loading quick enough. Use
local ModuleExample = require(script:WaitForChild("ModuleExample"))
April 29, 2021, 4:20pm
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
Roblox made changes recently to load order