ReferenceScripts

decompile

Turns a script's bytecode back into readable Luau source.

Syntax

decompile(source: LuaSourceContainer | string, options: DecompilerOptions | number?) -> string

Parameters

ParameterTypeDescription
sourceLuaSourceContainer or stringA script, or a string of Luau bytecode.
optionsDecompilerOptions or number?Formatting options from DecompilerOptions, or a time limit in seconds.

Returns

TypeDescription
stringRecovered Luau source; review it before use.

Description

Local variable names and comments are not stored in bytecode, so the output uses generated names. The decompiler attempts to recover structure, constants, calls and control flow. Complex or unsupported bytecode can produce incomplete or incorrect output; equivalence is not guaranteed. Decompiling runs off the game thread and yields until it is done. Timeouts and cancellation stop delivery of a result; they do not promise immediate termination of an already-running native decompiler job.

Example

local source = decompile(game.Players.LocalPlayer.PlayerScripts.ClientMain)
writefile("ClientMain.luau", source)

local options = DecompilerOptions.new()
options.Formatter.IndentWidth = 2
print(decompile(getfunctionbytecode(function() return 1 end), options))

Notes

These are Game executor contracts. Check build requirements and session lifetimes before using them.