ReferenceScripts

require

Loads a ModuleScript and returns its result, from your scripts.

Syntax

require(module: ModuleScript) -> any

Parameters

ParameterTypeDescription
moduleModuleScriptThe module to load.

Returns

TypeDescription
anyThe 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

These are Game executor contracts. Check build requirements and session lifetimes before using them.