Environment
Reach the global environments of Lynx, Roblox and running scripts.
Every Luau script has an environment: the table its globals live in. Lynx gives you access to its own, to Roblox's, and to the environment of any running script.
Global environments
getgenv
since 1.0.0getgenv(): tableReturns the Lynx global environment. It's shared by every script you execute: define something there and your next script can use it. Game scripts can't see it.
Returns
tableThe Lynx global environment.
Example
getrenv
since 1.0.0getrenv(): tableReturns the Roblox global environment, the one game scripts share. Changes here are visible to every game script.
Returns
tableThe Roblox global environment.
Example
getsenv
since 1.0.0getsenv(script: LocalScript | ModuleScript): tableReturns the environment of a running script: its globals, including functions it defined without local. Errors if the script isn't running.
Parameters
scriptLocalScript | ModuleScript- A script that is currently running.
Returns
tableThe script's environment.
Example
Registry and garbage collector
getreg
since 1.0.0getreg(): tableReturns the Luau registry, the internal table Roblox uses to keep threads, connections and callbacks alive. Most useful for finding threads.
Returns
tableThe registry.
Example
getgc
since 1.0.0getgc(includeTables: boolean?): {any}Returns every function and userdata the garbage collector is tracking, plus tables when includeTables is true. The result can hold hundreds of thousands of values in large games, so filter early.
Parameters
includeTablesboolean?- Optional.Include tables in the result. Default
false.
Returns
{any}An array of collectable values.
Example
Scripts
getloadedmodules
since 1.0.0getloadedmodules(): {ModuleScript}Returns every ModuleScript that has been required on the client.
Returns
{ModuleScript}Loaded modules.
Example
getrunningscripts
since 1.0.0getrunningscripts(): {BaseScript}Returns every script currently running on the client: LocalScripts, client-side Scripts and loaded ModuleScripts.
Returns
{BaseScript}Running scripts.
Example
Written for Lynx 0.0.0
Something unclear? Tell us on Discord