ModuleScript
Inherits LuaSourceContainer
ModuleScript contains Lua code that returns a value which can be required by other scripts.
Examples
-- In ModuleScript
local module = {}
function module.greet(name)
return "Hello, " .. name
end
return module
-- In another Script
local myModule = require(script.Parent.ModuleScript)
print(myModule.greet("World"))
Properties
ModuleRef
intReference to the cached module value in the Lua registry
Loaded
boolWhether the module has been loaded and cached
When true, the script can execute; when appropriate.
The Lua source code to execute.
File path to fetch and load source code from.
Methods
Require()
intLoads and returns the module value
local module = require(game.ServerScriptService.MyModule)