Returns the game’s global environment, the Luau globals the game’s own scripts see, including game, workspace, and the standard libraries.

Returns

table
A read-through view of the game environment. Indexing it reads the game’s globals; assigning to it writes through to them.

Behavior

getrenv does not hand back the raw internal globals table. It returns a view layered over the game environment so that reads and writes reach the real globals while Athena’s own internals stay hidden:
  • Reads and writes pass through to the game environment via the view’s metatable, so getrenv().game is the game and getrenv().workspace is the workspace.
  • _G and shared on the view are the game’s shared tables, not Athena’s, so scripts inspecting the game environment see what the game sees.
  • Replaced globals are reflected. Globals Athena intentionally overrides (such as print and warn) appear on the view as the active implementations, so the environment is internally consistent.
Reach for getrenv when you want the game’s own globals and libraries, and getgenv when you want a place to keep your own values. They’re different tables with different lifetimes, and mixing them up is a common source of confusing behavior.

Example

Reach a service through the game environment:

Errors

getrenv does not raise under normal conditions. If the game environment cannot be captured at all, the call errors with the game global environment could not be captured.
  • getgenv: Athena’s environment.
  • gettenv: a specific thread’s globals.