Skip to content
Saiko

debug.setconstant

Overwrites a constant inside a function, changing its behaviour without rewriting it.

Signature

luau
debug.setconstant(fn: function | number, index: number, value: any): ()

Parameters

fnfunction | number

The function, or a stack level.

indexnumber

1-based constant index.

valueany

The replacement value, which must match the original type.

Returns

Nothing.

Example

luau
local function login()
    return "token-123"
end

debug.setconstant(login, 1, "patched")
print(login()) --> patched