Environment
Environment tables, registry and collector inspection.
Environment functions expose different parts of the current Luau VM:
getgenv()returns the executor environment.getrenv()returns engine globals.- Registry and collector helpers inspect objects reachable from the current VM.
These calls return live tables, not snapshots. The executor also installs its own _G and shared tables.
Other environment lookups include gettenv for a thread, getsenv for a reachable script, and getmenv for an already required module.
Share state in one VM
Values placed in getgenv() can be read by another executor script in the same VM:
local env = getgenv()
env.exampleCount = (env.exampleCount or 0) + 1
print(env.exampleCount)Running this again in the same VM increments the count. Use a distinctive key because other scripts can write to the same table.
Across Actors and teleports
An Actor can run in another VM. Its getgenv() state and collector objects are not automatically shared with yours. Pass required data explicitly when scheduling code in another VM.
VM boundary: A channel ID is known world-wide, but its channel table is per VM.
get_comm_channelmints one per VM, and only the creating VMs copy carriesEvent.
A teleport replaces the world. Recreate cached handles and per-world state in the destination. queue_on_teleport queues source text; it does not keep old objects alive.
Functions
| Function | Purpose |
|---|---|
| getgenv | Returns the shared executor environment. |
| getrenv | Returns the engine global environment. |
| getfenv | Reads the environment of a function or a stack level. |
| getreg | Returns the current Lua registry. |
| getgc | Lists functions and userdata reachable through the current VM collector. |
| getallthreads | Lists threads in the caller's VM. |
| filtergc | Finds collector functions or tables matching supplied criteria. |
| collectgarbage | Runs a full collection or forwards another collector operation to Luau. |
