i have a lot of functions in a local script, is storage them inside a module script a good idea?
1 Like
If you are wanting cleaner organization, it would be a good idea to put these functions in a ModuleScript.
You can have your ModuleScript containing all the methods (functions) for your main script which can then be called by your main script whenever necessary.
For example:
ModuleScript
local myModule = {}
function myModule.doSomething(message)
print(message)
end
return myModule
Main script:
local moduleScript = require(script.ModuleScript) -- Referencing the ModuleScript which is attached to the main script
moduleScript.doSomething("Hi") -- Prints "Hi" in the Output
1 Like