So I have a script that requires a module:

local Master = require(script.Parent.Master)

I have a bunch of modulescripts and in that module and it returns those other modules:

-- // Module Script \\ --
Master = {}

return table.unpack( 
	{
		Spawner = require(script.Spawner)
		Changer = require(Script.Changer)
		-- so on
	}
)

Is it possible to execute those required modules like this?

-- // Server Script \\ --
local Master = require(script.Parent.Master)

Spawner.new()
Changer.new()

Or returning the required modules in a different way?

-- // Module Script \\ --
Master = {}

return table.unpack(

	 {
		require(script.Spawner)
	 	require(Script.Changer)
		-- so on
	}
)

I don't want to clutter my script with 12 module lines. I could try grouping them up in bigger modules but that would be messy.

2 comments

0

No it is not. Unles you want yo get hacky and use setfenv. You sould only require module when they are needed as they should be lazy loaded.

0

Thank you