Scripts

Discover running scripts and modules, decompile and hash bytecode, load Luau source, and link scripts to their threads and environments.

Overview

Finding the scripts a game is running, reading what they compiled to, and loading your own code.

getrunningscripts and getscripts list what's running. getsenv opens a script's environment so you can read and change its locals. getscriptbytecode and getscripthash give you the compiled version, which is what decompilers work from.

Getting into a running script
for _, script in ipairs(getrunningscripts()) do
    if script.Name == "AntiCheat" then
        -- Read what the script itself declared.
        local env = getsenv(script)
        print(env.enabled)
        env.enabled = false

        -- Or work from the compiled form.
        print(getscripthash(script))
    end
end

getcallingscript tells you who called

Inside a hook, getcallingscript() gives you the script that made the call. Easiest way to filter a noisy hook down to one script.

Running scripts

Threads and environments

Bytecode

Loading

Four ways to load code depending on where it comes from: loadstring from a string, loadfile from the workspace, dofile loads and runs in one go, and runfile is the same but with the workspace path rules.