I have a module loader for my game which makes me easily require modules with just the name of the module, but the Types and autocomplete don’t get returned. Im wondering if anyone else whos more experiences with types and all that stuff could help me here.
function module.GetModule(moduleName: string, model: boolean)
if typeof(libraryName) == "Instance" then
return require(libraryName)
elseif script.Client.Libraries:FindFirstChild(libraryName, true) then
if model then
return script.Client.Libraries:FindFirstChild(libraryName, true)
else
if Loaded.Libraries[libraryName] then
return Loaded.Libraries[libraryName]
else
local Module = require(script.Client.Libraries:FindFirstChild(libraryName, true))
Loaded.Libraries[libraryName] = Module
return Module
end
end
elseif SharedModules.Libraries:FindFirstChild(libraryName, true) then
if model then
return SharedModules.Libraries:FindFirstChild(libraryName, true)
else
if Loaded.Libraries[libraryName] then
return Loaded.Libraries[libraryName]
else
local Module = require(SharedModules.Libraries:FindFirstChild(libraryName, true))
Loaded.Libraries[libraryName] = Module
return Module
end
end
elseif RunService:IsServer() then
local ServerModules = ServerScriptService.Loader
if ServerModules.Libraries:FindFirstChild(libraryName, true) then
if model then
return ServerModules.Libraries:FindFirstChild(libraryName, true)
else
if Loaded.Libraries[libraryName] then
return Loaded.Libraries[libraryName]
else
local Module = require(ServerModules.Libraries:FindFirstChild(libraryName, true))
Loaded.Libraries[libraryName] = Module
return Module
end
end
end
end
if script.Client.Classes:FindFirstChild(libraryName, true) or SharedModules.Classes:FindFirstChild(libraryName, true) then
error(string.format("%s is an class-module, not a library.", libraryName))
else
error(string.format("Library %s not found.", libraryName))
end
end
Its not end of the world, but it definitely effects my workflow having to open every single module to see whats what. Not even sure if there’s a solution for this right now, I may have to wait for script editor plugins.