const
Updatedconst MAX_HP = 100 const LIMITS = { hp = 100 } LIMITS.hp = 1 -- allowed: the value is not frozen
A binding that cannot be reassigned. Luau has const of its own, so the keyword passes through and a reassignment is a compile error there too. The check follows scopes: a local or a parameter of the same name hides the const, and each name of const a, b and of const { a, b } is one.
The freeze is shallow: it holds the name to one value, and that value stays mutable. A field of a const table takes an assignment, an index takes one, and NAMES:push(x) grows a const array. The pedantic lint const_mutation reports the field and index assignments, so a project that reads const as deep can turn it on. It does not judge a method call, since the name of a method does not say whether it writes.
The word is also free as a name. const before a name, a function, or a destructuring bracket declares; const = 1, const(x), and const.field read the Luau way, so a local named const is a local.
