My output looks like this: 08:51:34.606 Sprint Sprint - Client - ClientLoader:33 08:51:34.622 Came - Pastebin.com
and my moduleloader looks like
local SP = game:GetService("StarterPlayer")
local loader = {}
local unloaded = {}
local loaded = {}
local finished = false
local whitelist = {
"Backpack",
"BuildModeHandler",
"Sprint",
"GuiHandler",
"CameraController",
"BuildModeInterface",
"AdminPanel"
}
local function FindFirstModule(key)
local module = SP:FindFirstChild(key, true)
return module:IsA("ModuleScript") and module or nil
end
function loader.new()
local _start = os.time()
for _, v in whitelist do
local module = FindFirstModule(v)
if not module then continue end
table.insert(unloaded, module)
task.spawn(function()
local suc, erm = pcall(function()
loaded[v] = require(module)
end)
print(v, module)
erm = erm or ""
if not suc then
warn("["..v.."] "..erm)
end
table.remove(unloaded, table.find(unloaded, module))
end)
end
print("Loader | Initialized in " .. (os.time() - _start) .. "ms")
finished = true
end
function shared:getModule(key: string)
repeat task.wait() until finished == true
local module = loaded[key]
if not module then warn("["..key.."] Module is not registered.") end
return module
end
return loader
So as you can see, the moduleloader gets done loading before most modules is actually loaded