So, I put my script in my a module, I played the game. The module didn't execute, so I redid the recalled the function. So, is module just additional adding recall to the function? Or they're just 2 different things?
modules work like a place to hold your code for later use try this example:
module:
local mod = {} function mod:Test()-- must include the name of your local up above ^^ print("test worked") end return mod--must be same as local
regular script:
require(script.Parent.mod):Test()
module scriupts work like a global function: here is what i mean.
in module
local module = {} -- declares an object module.sayHello() = function() print("Hello there good sir!") end return module
so the above declares an object variable in a module script named: module and then I give the object - module- a property named: sayHello
and then we return the whole object
here is another depiction:
local module = { sayHello = function() print("Hello good sir") end } -- declares an object return module
sayHello
is basically a variable of module.
now to call this global function - Module- we need to require()
it.
require is a function that is intended to be for getting modules in Scripts, Localscripts, - and even Module script-
In Server Script
local module = require(game.Workspace....) --<- this takes an Argument of the path of the target module module.sayHello() -- since it returns the table, we can just access its properties -- the above calls the function we fed to the module