Yuari
Documentation
Docs/Environment

Environment

Global, game and script environments plus GC inspection.

Returns the executor global environment.

getgenv().myValue = 123
print(getgenv().myValue)

Returns a cached view of the Roblox global environment, including _G and shared.

local env = getrenv()
print(env._G, env.shared)

Returns the environment table of a script instance.

local script = getscripts()[1]
print(getsenv(script))

Returns a ModuleScript environment. This always returns a table; an empty table is used when no environment is resolved.

local module = getloadedmodules()[1]
print(getmenv(module))

Returns a function environment table.

local function f() end
print(gettenv(f))

Returns the Lua registry (also documented under Core).

print(getreg())
print(getregistry())

Returns reachable GC objects. Pass true to include tables.

for _, object in ipairs(getgc(true)) do
    if type(object) == "table" then
        print(object)
        break
    end
end

Filters the GC heap by type (table, function, thread, userdata, buffer) with an options table, or by a predicate function.

local functions = filtergc("function")
print(#functions)
local tables = filtergc(function(value)
    return type(value) == "table"
end)
print(#tables)

Returns the current script globals together with the shared table.

local globals = getscriptglobals()
print(globals._G == getgenv())

Returns true when the current thread belongs to the executor.

print(isexecutorthread(), isourthread())