Scripts
Decompile scripts, read their bytecode and create closures from them.
These functions work on any script whose bytecode reached your PC: LocalScripts, ModuleScripts and client-side Scripts. Decompiling scripts explains what never does.
Source
decompile
since 1.0.0Yieldsdecompile(script: LocalScript | ModuleScript | Script | string): stringDecompiles script and returns Luau source. A string is treated as bytecode, such as the result of getscriptbytecode.
When a script can't be decompiled, the result is a Luau comment that says why instead of an error. Functions aren't accepted.
Parameters
scriptLocalScript | ModuleScript | Script | string- A script with client-side bytecode, or a bytecode string.
Returns
stringThe reconstructed source, or a comment with the reason it failed.
Example
Bytecode
getscriptbytecode
since 1.0.0getscriptbytecode(script: LocalScript | ModuleScript | Script): stringReturns the raw Luau bytecode of script as a binary string.
Also available as dumpstring.
Parameters
scriptLocalScript | ModuleScript | Script- A script with client-side bytecode.
Returns
stringThe bytecode.
Example
getscripthash
getscripthash(script: LocalScript | ModuleScript | Script): stringReturns a SHA-384 hash of script's bytecode as a hex string. Two scripts with the same hash are byte-for-byte identical, which makes this a quick way to notice when a game updates a script.
Parameters
scriptLocalScript | ModuleScript | Script- A script with client-side bytecode.
Returns
string96 hex characters.
Example
getscriptclosure
since 1.0.0getscriptclosure(script: LocalScript | ModuleScript | Script): functionCreates a new function from script's bytecode: its main chunk, not yet run. Calling it runs a separate copy of the script in your thread, leaving the original untouched.
Also available as getscriptfunction.
Parameters
scriptLocalScript | ModuleScript | Script- A script with client-side bytecode.
Returns
functionThe script's main function.
Example
Written for Lynx 0.0.0
Something unclear? Tell us on Discord