ReferenceScripts

getmenv

Returns the globals table of a ModuleScript.

Syntax

getmenv(module: ModuleScript) -> table?

Parameters

ParameterTypeDescription
moduleModuleScriptA ModuleScript that has been required.

Returns

TypeDescription
table?The module's global environment, or nil when it has not run.

Description

It is getsenv for modules. The table is the environment the module's code actually ran with; a module that nothing has required yet has none, and Apex does not make one up.

Example

local module = game.ReplicatedStorage.Modules.Inventory
require(module)
print(getmenv(module))

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