getfenv
Accesses a function or thread environment.
Syntax
Signature
getfenv(Target: (function | thread | number)?) -> tableAliases
This function has no aliases.
Parameters
| Parameter | Type | Description |
|---|---|---|
Target | (function | thread | number)? | Function, thread, or nonnegative stack level. Defaults to 1. |
Returns
| Type | Description |
|---|---|
table | Live environment table. |
Notes
Returns the environment of a function, thread, or stack level. The default level is 1. Level 0 selects the current thread. For a C closure, returns the calling thread's global environment.
Example
Luau
local Function = function() return Value end
print(getfenv(Function))