Decompiling scripts

Turn compiled LocalScripts and ModuleScripts back into readable Luau with decompile().

Roblox sends client-side scripts to your PC as compiled Luau bytecode. decompile turns that bytecode back into source you can read, search and learn from.

One script

Lynx has no decompiler view: decompile is a function your scripts call. It returns the source as a string. Write it to the workspace, then open the file from Files in the sidebar.

decompile-one.luau
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local module = ReplicatedStorage:FindFirstChildWhichIsA("ModuleScript", true)
if module then
writefile(module.Name .. ".luau", decompile(module))
end

Many scripts

A loop decompiles a whole folder of the game into a folder of your workspace.

dump-player-scripts.luau
local Players = game:GetService("Players")
local playerScripts = Players.LocalPlayer:WaitForChild("PlayerScripts")
makefolder("decompiled")
for _, object in playerScripts:GetDescendants() do
if object:IsA("LocalScript") or object:IsA("ModuleScript") then
local source = decompile(object)
local name = object:GetFullName():gsub("[^%w%.%-]", "_")
writefile("decompiled/" .. name .. ".luau", source)
end
end

What to expect

decompile yields while it works, then returns a string:

  • On success, the reconstructed Luau source.
  • On failure, a Luau comment that says why, for example that the bytecode is empty. It doesn't raise an error, so check the result before you trust it.
  • Bytecode works too. Pass the string from getscriptbytecode instead of a script.

Bytecode keeps the structure of a program, but not everything the author wrote. Comments and type annotations are never recovered, because they don't exist in bytecode.

What can't be decompiled

  • Server scripts. A Script that runs on the server never reaches your PC. There's no bytecode to decompile.
  • Anything that stays on the server. Scripts in ServerScriptService and ServerStorage are never replicated to clients.
  • Functions. decompile takes a script or bytecode. Passing a function raises an error.

A whole place

saveinstance() saves the place you're in as a Roblox place file and decompiles its scripts on the way. Pass { Decompile = false } to skip the decompiling and save faster.