index in a Luau function’s constant table with value.
Parameters
Returns
void - the target’s constant table is mutated in place.
Aliases
setconstant
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
index in a Luau function’s constant table with value.
debug.setconstant(func: function | number, index: number, value: any): ()
| Parameter | Type | Description |
|---|---|---|
func | function or number | The Luau function to patch. |
index | number | Which constant to replace. |
value | any | The replacement value. |
void - the target’s constant table is mutated in place.
setconstantdebug.setconstant(function(...) end, 1, "test")
local function getMaxAmmo()
return 30
end
print(getMaxAmmo()) --> 30
-- index 1 is the number literal 30, the only constant in this body
debug.setconstant(getMaxAmmo, 1, 999)
print(getMaxAmmo()) --> 999