getrenv

Returns the game's global environment table.

Syntax

getrenv() -> table

Returns

TypeDescription
tableThe game's global environment

Description

getrenv returns the global environment used by game scripts. This contains standard globals such as game, workspace, and Instance.

Example

local renv = getrenv()

-- Access game globals
print(renv.game)      -- Same as game
print(renv.workspace) -- Same as workspace
print(renv.Instance)  -- Same as Instance

Finding Game Globals

-- List all globals in the game environment
local renv = getrenv()
for name, value in pairs(renv) do
    print(name, type(value))
end

Difference from getgenv

getrenv()getgenv()
Game's environmentVolt's environment
Contains game globalsContains Volt globals
Read-only access recommendedCan 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
  • getgenv - Get Volt's environment
  • getsenv - Get a script's environment