require
Loads a ModuleScript and returns its result, from your scripts.
Syntax
require(module: ModuleScript) -> any
Parameters
| Parameter | Type | Description |
|---|---|---|
module | ModuleScript | The module to load. |
Returns
| Type | Description |
|---|---|
any | The value the module returned. |
Description
This is the engine's require with one difference: when the engine refuses a module because of the calling context, as it does for modules the game's own scripts use, Apex runs the request again from a game-script context. It shares the engine's module cache, so requiring a module the game already loaded returns the same value the game received.
Example
local Network = require(game.ReplicatedStorage.Modules.Network)
for name in Network do
print(name)
end
Notes
- Errors raised while the module runs are passed through.
These are Game executor contracts. Check build requirements and session lifetimes before using them.
