getgenv
Returns the executor's shared global table.
Syntax
getgenv() -> table
Also available as
get_genv
Returns
| Type | Description |
|---|---|
table | The shared executor environment for the current game. |
Description
Every script you run in the same game reads its globals through this table, so a value stored in it is visible to all of them. It stays the same table for as long as you are in the game, and starts fresh when you join another one.
A plain global assignment in a script, such as x = 1, stays in that script's own table and is not shared. Write to getgenv() when you want other scripts to see a value. Names that neither table defines fall through to the game's globals, so game, workspace and print work as usual.
Example
getgenv().Settings = { Enabled = true }
loadstring("print(Settings.Enabled)")()
x = 1
print(getgenv().x)
Notes
- This is a separate table from
getrenv. Passing environment tables or closures to other code explicitly shares those references.
These are Game executor contracts. Check build requirements and session lifetimes before using them.
