That approach of looping through modules with GetDescendants() is actually pretty common and works nicely if done right.
First up, GetDescendants() is an instance method that gives you every child at any depth under a parent—works like scanning the entire tree in one go.
You can find the official docs for it here: look up “Instance:GetDescendants” in the Roblox Creator documentation Roblox Creator Dashboard. Its also explained in community guides like the Roblox Wiki Roblox Wiki!
That pattern of building a loader that scans folders requires each ModuleScript stores them in a cache and then lets you fetch them by name is a really good way to handle things…
local Loader = {}
local cache = {}
function Loader.Require(folder)
for _, item in ipairs(folder:GetDescendants()) do
if item:IsA("ModuleScript") then
local name = item.Name
cache[name] = require(item)
end
end
end
function Loader.Get(name)
return cache[name]
end
return Loader
This shows a similar structure from a DevForum thread where someone defined a loader that also handled “__load” and “__init” hooks and even assigned a global function _G.Get to fetch modules by name Developer Forum | Roblox!!
Another approach is from Sleitnicks RbxUtil.Loader… it provides utilities like LoadDescendants() to require all module scripts beneath a given folder, optionally filtering by name, and even SpawnAll() to automatically call a method like OnStart on each module. It looks something like this:
local modules = Loader.LoadDescendants(ReplicatedStorage.MyModules, Loader.MatchesName("Service$"))
Loader.SpawnAll(modules, "OnStart")
This scanning, requiring and initializing makes managing lots of modules much smoother sleitnick.github.io.
So yeah, your method of scanning once, caching modules and grabbing them via a lookup function is solid and very often used. If you want to extend it adding optional lifecycle hooks like __load or OnStart can make setup even cleaner!
And hooking into GetDescendants is very efficient as long as the folder you scan doesnt change too dramatically during runtime!
Hope that helps and gives you some ideas on whatever your doing!!