Can you return variables to a server script from a module script?

Hi,

I can’t remember if you can return variables when calling a module script function from a server script. Is it currently possible? I tried return but that didn’t work.

Thanks.

1 Like

Simple, just use the return keyword.

ServerScript

local add = require(script.ModuleScript).add

local sum = add(2, 4)
print(sum)

ModuleScript

local module = {}

function module.add(n1, n2)
    return n1 + n2
end

return module

Not sure why it wasn’t working, I did exactly this but seems to be working now. Thanks.