Require() doesn't require half of the modulescripts

So I made a script that requires all modulescripts and runs their function.

But for some reason, it doesn’t require all the modulescripts and only requires half of the stuffs in the script.

all modulescripts:


this is what I get when I print the required modulescripts.

Try using ipairs instead of pairs. ipairs is for arrays, pairs is for dictionaries.

Put the require(v)() in its own thread. You are running each module and its ending on one that has a loop or something.

not like it will fix the problem, pairs can also be used on arrays

There could be something yielding the load process, try to wrap the require in a spawn?

for i, v in pairs(script:GetChildren()) do

It’s probably that the modules haven’t loaded in, so you could add a ChildAdded event then require and print in that.


The modules are a child of the script. If the script exists, so would the modules. Also im pretty sure require() has a built-in wait so something like this won’t be needed. At least I think ive read that somewhere before.

I don’t get why there is such a fuss.
The module process stops at Teleport, so Time Cycle might have a while loop or some sort of wait that blocks the for loop from minding it’s own business.

The easiest workaround to this is to wrap whatever’s causing the issue in the time cycle script in a different thread, or to just wrap the require in a different thread. (which I just demonstrated)

Couldn’t it be the other way around, since children are based on the parent, but parent isn’t based on the children existing?

@swatj1an But it’s about loading the modules right? So getting the children at a time when not all of the children are there would mean that it wouldn’t load in ones that got loaded in after. But what you said is right, if there is a yielding statement that would stop the execution of the other modules.

So I was in a rush wasn’t thinking straight after putting the while true do loop time cycle thing (that I just copied in the toolbox) into the modulescripts and I tried wrapping it and it works fine now

return function()
		while true do
1 Like

Scripts in ServerScriptService don’t “Load in” as they are already there at run-time, because it’s the server, not the client. Stuff loads on the client, which is why you use WaitForChild a lot for client stuff. Server stuff should already instantly have access to things in its Storage locations.

Oh ok, I didn’t know that, thank you.

1 Like