ServerScript
local Mod = require(game.Workspace.ModuleScript) game.Workspace.Value.Value = Mod.Return()
Module_Script
local module = {} function Return() return 40 end return module
game.Workspace.Value is a intvalue and its value isnt changing to 40 for some reason
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:
--Script local module = require(workspace.ModuleScript) --grab the module local numValue = game.Workspace.NumValue numValue.Value = module.Return() --return function returns 40, value is now equal to 40
ModuleScript:
--Module local module = {} --Table function module.Return() --Add function to table return 40 end return module --return the 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.
You're still not doing what I told you to. Use
local module = {} function module.Return() return 40 end return module