Issues with requiring multiple modules at once

Hello, I’m attempting to make a script that will require all modules in the child of the script. But when the code hits the requiring area, It grounds to a total halt and does not require any service.

local Services = {}

	for _, v in pairs(script:GetChildren()) do
		if v:IsA("ModuleScript") then
			Services[v.Name] = require(v)
		end
	end

I’ve tried printing the Services table, after i wrapped the code in spawn(function() but comes out empty.

Connect a ChildAdded event to add a service

The script gets grounded to a halt during this part, I dont see how a ChildAdded event would help really

I have this same code in other areas of my game and it works perfectly fine there, But not here.

Because there is no telling when a module is gonna load in.

Also I don’t know what you mean by “grounded to a halt”

Grounded to a halt basically means “Stops”

I’ll try out your answer and see if that helps.

Which names ModuleScripts have?

I’m sorry I don’t know what you mean by this

I about propertie Name, not in script, in studio.

Like module scripts names.

Theres a few modules, the names are as following;
VehicleHandler
ToolHandler
JusticeHandler;
Properties;
ProximityHandler

There will be more added soon

Did my solution work for you or what?

No, It didn’t work. But I appreciate the suggestion

Can I see the code you made using my suggestion?

Not at the moment, I’m about to head down to the store.

How is the hierarchy setup?

Maybe loop through descendants instead?

local Services = {}

for _, child in script:GetDescendants() do
   if not child:IsA("ModuleScript") then
      continue
   end

   Services[child.Name] = require(child)
end

Will try this and get back to you.

Seemingly made no change. I’m clueless at whats happening at this point, As I said earlier I use the same code in other areas of the game, and it works there, but oddly enough not here

How is the hierarchy setup? The only thing it could be is the script has no children.

Heres how its setup.

LocalScript

  • Folder containing a few not important modules
  • About 6 ModuleScripts

Could you provide a screenshot if possible and any errors that have occured?