✓ Accepted answer
Ah, you were close.
Basically, a module is a table.
How do we add things into tables? Well we can do it a number of ways.
You can use dot syntax, brackets, etc.
So if we have a table called module (module = {}), then we need to add a function into that table.
You do that by doing function module.Func() end
ServerScript:
local module = require(workspace.ModuleScript)
local numValue = game.Workspace.NumValue
numValue.Value = module.Return()
ModuleScript:
local module = {}
function module.Return()
return 40
end
return module
If you want a bit deeper understanding, then you should also know that we're using syntax sugar whenever we do function module.Func() end.
Normally you'd have to do something like this:
module.Func = function() end but luckily we have something thats much easier to read now.
3 comments
My wordings a bit off, a module isnt exactly a table* it returns a table with whatever you put in it. Sorry about that, but everything else is more or less correct here. I wont bother changing it
Hey they don't have to return a table but this is correct apart from that
Thanks haha.