Scripts
The script functions provide access to script environments and internal state.
getgc
Returns a list of objects in the Luau garbage collector.
If includeTables
is false, tables will not be included in the list.
Parameters
includeTables
- Whether or not to include tables in the list.
Example
TODO - Write a real-world example use case.
getgenv
Returns the custom global environment of the executor. It can be used to add global functions or share variables between scripts.
Example
Prevent a script from being run twice:
getloadedmodules
Returns a list of ModuleScripts that have been loaded. If excludeCore
is true, CoreScript-related modules will not be included in the list.
Parameters
excludeCore
- Whether or not to exclude core modules from the list.
Example
getrenv
Returns the global environment of the game client. It can be used to access the global functions that LocalScripts and ModuleScripts use.
Example
Prevent scripts in PlayerScripts from being required:
getrunningscripts
Returns a list of scripts that are currently running.
Example
getscriptbytecode
Returns the raw Luau bytecode of the given script.
Parameters
script
- A client-running LocalScript or ModuleScript.
Aliases
dumpstring
Example
getscriptclosure
Generates a new closure using the bytecode of script
.
Parameters
script
- The script to recreate.
Aliases
getscriptfunction
Example
Compare the return value of a ModuleScript:
getscripthash
Returns a SHA384 hash of the script's bytecode. This is useful for detecting changes to a script's source code.
Parameters
script
- A client-running LocalScript or ModuleScript.
Example
getscripts
Returns a list of every script in the game.
Example
getsenv
Returns the global environment of the given script. It can be used to access variables and functions that are not defined as local.
Parameters
script
- A client-running LocalScript or ModuleScript.
Example
getthreadidentity
Returns the identity of the current thread.
Aliases
getidentity
getthreadcontext
Example
setthreadidentity
Sets the current thread identity.
Aliases
setidentity
setthreadcontext
Example
Last updated