AcediaDocumentation

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_channel mints one per VM, and only the creating VMs copy carries Event.

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

FunctionPurpose
getgenvReturns the shared executor environment.
getrenvReturns the engine global environment.
getfenvReads the environment of a function or a stack level.
getregReturns the current Lua registry.
getgcLists functions and userdata reachable through the current VM collector.
getallthreadsLists threads in the caller's VM.
filtergcFinds collector functions or tables matching supplied criteria.
collectgarbageRuns a full collection or forwards another collector operation to Luau.

On this page