First arg of modulescript function disappears

I am trying to pass arguments through a function using indexing and the first argument always turn into nil.

--module
local module = {}
function module:Test(a,b,c)
    print(a,b,c)
end)
--serverscript
local module = require(script.Parent.ModuleScript)
module['Test']('a','b','c')

image

Any help is appreciated.

You need to replace the last line with this:

module['Test'](module, 'a','b','c')
1 Like

a:b(c) is sugar syntax for a.b(a, c). a.b is sugar syntax for a["b"]. So you need to call with a colon or pass module as the first argument. Don’t define all module functions with the colon, this sugar syntax makes passing the function as an argument to another function a pain.

4 Likes