local module = {}
function module:GetService(ServiceName)
setmetatable(ServiceName, {
__index = function()
return {
warn("Couldn't Find The Service.")
}
end;
})
for Service, _ in pairs(script:GetChildren()) do
if ServiceName == script[Service] then
require(script[ServiceName])
end
end
end
return module
Main:
local ServicesModule = require(script.Services)
ServicesModule:GetService("Example1")
You’ll need to require the module first, and then require the other module…
If you were working with multiple scripts, that’s so redundant. You are basically writing that whole code just to do require(path.to.module). So whats the point?
Services Managing Module Requires The Services Inside It By Using :GetService, Main Script Requires The Service Managing Module That Requires The Modules Inside The Modulescript;
The code is going to produce errors since the setmetatable part is incorrect. script[Service] will also produce errors. You are requiring the module script inside the function but never returning it, hence the required module can’t be used outside of the Service module.