Skip to main content
Returns the global environment that the Roblox game uses - separate from getgenv(),
which shows executor-exclusive environment.
The returned table holds _G and shared directly. Pulls every other global (print, game, task, require) via using a metatable. Almost all globals are the same closure your script sees - getrenv().print == print is true. The exceptions are require, debug, and loadstring - Seliware’s copy and the game’s copy are different functions for these three. Using getrenv().require catches the game’s calls and leaves yours alone.
When dealing with running ModuleScripts, avoid the global require(), and instead use getrenv().require() to avoid leaking the script’s environment.Don’t forget to setidentity(2) first!

Returns

Example

When dealing with running ModuleScripts, avoid the global require(), and instead use getrenv().require() to avoid leaking the script’s environment.Don’t forget to setidentity(2) first!