Skip to main content
Replaces the constant at index in a Luau function’s constant table with value.
New to constants? Learn more here. The replacement takes effect the next time that function runs. Pass a Luau function to target its constant table, or a number for the running function at that stack level. Indices come from the compiled constant table, not the source you read. The compiler folds math and string concatenation and strips dead code, so a decompiled listing may not line up one-to-one. Most often used to change a value a game’s code checks against: swap the number or text it compares to, and a check that should fail can pass instead.

Parameters

Returns

void - the target’s constant table is mutated in place.

Aliases

  • setconstant

Example

In a Roblox game, a function returns a hardcoded number you want to override. Find the constant’s index, then repatch it.
Modifying constants affects all subsequent calls to the targeted function.