Skip to main content
Returns the executor’s global environment - a shared table across all scripts in the same Roblox session. Userscripts can add values to it, but they’re gone the moment you leave a Roblox game.

Returns

Reaching Roblox globals through getgenv() (like getgenv().print) works, but there is no reason to - they are already in scope, so call print, task, and the rest directly. The one exception is require: use getrenv().require for the game’s copy, covered on the getrenv page.

Example

In a Roblox game, stop your script from running twice - executing it again stacks hooks and breaks what the first run set up.
Use this table to share variables and utility modules between scripts.