debug.setconstant
Overwrites a constant inside a function, changing its behaviour without rewriting it.
Signature
debug.setconstant(fn: function | number, index: number, value: any): ()Parameters
fnfunction | numberThe function, or a stack level.
indexnumber1-based constant index.
valueanyThe replacement value, which must match the original type.
Returns
Nothing.
Example
local function login()
return "token-123"
end
debug.setconstant(login, 1, "patched")
print(login()) --> patched