Hey Developers, I’ve been working on a UI system and most of it is Module scripts. I’m having trouble actually getting them to run tho.
Here’s how it’s set up: script lib contains all of the tweenings, the intro is the module script that contains the intro to run and core is the main UI. But every time I run the game it doesn’t load the module. I also want to have this placed in Playerstarterscripts if that is possible.
You can have this is PlayerStarterScripts. In your example, to use the module scripts it looks like Hub would need to require(this.Intro) and require(this.Core). Depending on what is in your module scripts, Hub would probably need to call Intro.ShowGui() etc. for it to actually do something.
If you don’t want to require every single module, you can try and use this script:
local modules = {}
for _, module in ipairs(script:GetChildren()) do
modules[module.Name] = require(module)
end
return modules
This will return a table with all the children modules. Use it in this setup:
The code should be placed in UITools and Libraries or any other module that contains other modules inside of it.
Basically, it’s a replacement for a folder. You can then do:
local uiTools = require(thePath.UITools)
-- And use all modules that are inside instead of requiring each one
uiTools.Core.MyCoolFunction()
uiTools.Libraries.MyAwesomeTweenHelper()
Also make sure that your modules return all of the values inside them, like the functions. Eg:
-- The Core module
local core = {}
function core.MyCoolFunction()
-- Your code
end
return core -- If you don't do this, it's empty as far as other scripts know