Help with MainModule

So I made a require module script or a loader. How do I make the script locate all of these localscripts inside of this model called Functions.

You’d just have to index them all manually.

local Functions = script.Functions
local Flash = Functions.Flash

etc

Doing local Functions = script.Functions won’t load what’s inside?

local Scripts = {}
for i,Script in pairs(script.Functions:GetChildren()) do
    Scripts[Script.Name] = Script
end
1 Like

If you ever look at any admin script, you’ll see under the MainModule they have a localscript similar to you. Requiring the ID like that will still be able to see its descendants like localscripts.

1 Like

If you require() it into a game, it automatically loads the descendants.

1 Like

Does this get all the localscripts inside the Functions model?

Yes it will, but I suggest using a folder instead of a model.

1 Like

I apologize, but I am really new to lua. I have no idea what mistake I did here because I got an error in the output when requiring the MainModule.
image

local module = {}
password = 123456789
function module.TBHandler(argument)
	if argument == password then
		local Scripts = {}
		for i,Script in pairs(script.Functions:GetChildren()) do
			Scripts[Script.Name] = Script
		end 

	end
end

return module

local module = require(moduleid, password)

is that what youre require arguments look like?

Make sure you’re running require(moduleid).TBHandler(123456789)

1 Like

image This happened. If I am supposed to put the id again on the bracket this prints out:image

No, do require(the id of your module, the thing you blacked out in the picture).TBHandler(whatever the password variable is inside of your module)

How do I get the ID of the module? Do I publish the MainModule to the roblox library?

What is the scribbled out number in the screenshots? Is it the password or the moduleid. If you want to be able to do require(moduleid) then you need to publish the module and make it public

2 Likes