getrenv
Returns the game's global environment table.
Syntax
getrenv() -> tableReturns
| Type | Description |
|---|---|
table | The game's global environment |
Description
getrenv returns the global environment used by game scripts. This contains all standard Roblox globals like game, workspace, Instance, etc.
Example
local renv = getrenv()
-- Access game globals
print(renv.game) -- Same as game
print(renv.workspace) -- Same as workspace
print(renv.Instance) -- Same as InstanceFinding Game Globals
-- List all globals in the game environment
local renv = getrenv()
for name, value in pairs(renv) do
print(name, type(value))
endDifference from getgenv
getrenv() | getgenv() |
|---|---|
| Game's environment | Volt's environment |
| Contains Roblox globals | Contains volt globals |
| Read-only access recommended | Can freely modify |
Checking for Global Modifications
-- Check if game modified a global
local renv = getrenv()
if renv.print ~= print then
warn("print function was modified!")
end