How would you grab all the functions of a module script and put it into a table.
Heres something I tried but It wouldn't work!
for i, v in pairs(plateModule) do if (type(v) == 'function') then if i == math.random(1, 4) then v(player, plate) end end end
you can actually do it automatically like this
for i, v in pairs(getfenv()) do if (type(v) == 'function') then if i == math.random(1, 4) then v(player, plate) end end end
but unless it’s for fun... please NEVER do this. the way others have suggested is far better, because doing this has a lot of problems if you could not guess already.
Can't you directly assign the functions inside of the module script like this?
function a() end function b() end return { funs = {a, b} }
Like this you could get a table of functions from another script by just doing
local funs = require(moduleScript).funs
Also, use "typeof" instead of "type". Type only supports vanilla lua types while typeof includes all robloxs classes
you can do this in the module script
local module = {} function module.function(args,args,args) -- can be module:function() too -- your function here return (what you wanna return here, delete this line if you dont wanna return anything) end function module.function2(args,args,args) -- btw, args stands for arguments aka parameters. -- i think you know what am doin return (what you wanna return here, delete this line if you dont wanna return anything) end return module
then, you can use that function in serverscripts and local scripts like this:
local module = require(insert module script here) module.function(args,args,args)