Intended:
myModule = require(myModuleScript)
myModule()
I forgot how to accomplish. Every example references something similar to myModule.innerFunction() but I don't want that. I swear I've done it before
Intended:
myModule = require(myModuleScript)
myModule()
I forgot how to accomplish. Every example references something similar to myModule.innerFunction() but I don't want that. I swear I've done it before
You can just return a function???
— module
return function()
print("nice")
end
—script
local module = require(module)
module() —> nice
and like saSlol said, you can utilise the __call metamethod to call the table.
Nevermind my brain hurts. This is impossible as the require function simply inferences a dictionary of functions.
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
If your return value in 'myModuleScript' is a table, you could try using metatables and the __call metamethod. Using this, you can utilize a table with information AND you can call the table(https://developer.roblox.com/articles/Metatables in Metamethods section).