debug.setconstant
C closures are not supported
This function will throw an error if called on a C closure, such as print
, since C closures have no accessible constants.
Mutable globals
If game
is a mutable global, the constant indexes will be different.
debug.setconstant
modifies a constant at the specified index in a Luau function bytecode.
This can be used to change hardcoded behavior within functions without modifying their source code - although it requires knowing the correct constant index beforehand.
function debug.setconstant(func: (...any) -> (...any) | number, index: number, value: number | string | boolean | nil): ()
Parameters
Parameter | Description |
---|---|
func |
The Lua function (or stack level) whose constant to modify. |
index |
The position of the constant to change. |
value |
The new constant value to set. |