Luau Core Language
When to Load
Load for pure Luau syntax and semantics: truthiness, tables, iteration, functions, scope, operators, string patterns, and ports from JavaScript or Python. Use roblox-luau-types for type annotations, roblox-luau-patterns for ownership and lifecycle, and domain skills for Roblox APIs.
Quick Reference
- Only
false and nil are falsy. 0, "", and {} are truthy.
- Equality does not coerce types.
0 == "0" is false. Inequality is ~=.
- Array conventions are 1-based.
#array is meaningful only for a sequence without nil gaps.
- Assigning
nil removes a table key. Assigning a table copies the reference. table.clone is shallow.
- Dictionary iteration order is unspecified. Do not make behavior depend on it.
- Dynamic keys require brackets:
record[field]. Dot syntax uses a literal identifier.
- Missing arguments become
nil; extra results and arguments can be discarded by context.
- Prefer an
if expression over condition and a or b when a may be false or nil.
- Local names are scoped from their declaration onward. Forward-declare mutually recursive functions.
- Luau string patterns are not regular expressions. Their syntax and capabilities differ.
- Backtick interpolation and
.. concatenation are both valid. Choose the clearer form; collect many fragments and join once in a hot loop.
- NaN does not equal itself and defeats
</> comparisons; test with x ~= x.
- Binary data uses the
buffer library: fixed size, 0-based offsets, explicit-width reads/writes. Avoid buffer.readinteger/writeinteger (stubs only, not released runtime).
- For Base64, hashing, or compression use
EncodingService (buffers, not strings; JSON still via HttpService). Details: see full reference.
local label = if enabled then "On" else "Off"
local message = `{name}: {score}`
local byId: {[number]: string} = {}
byId[userId] = name
for index, value in values do
print(index, value)
end
Translation traps
- JavaScript
===, !==, null, optional chaining, spread, arrow functions, and array methods are not Luau syntax.
- Python
None, zero-based list assumptions, list comprehensions, exceptions, and implicit tuple behavior do not translate directly.
x or fallback tests truthiness, not only absence. It replaces a valid false value.
typeof(value) recognizes Roblox datatypes; type(value) reports the underlying Luau type category.
Review
Valid Luau, no nil gaps in sequences, no assumed dictionary order, no accidental aliases, no cross-language syntax, no boolean expressions hiding false or nil.
Detailed language traps and translation examples: references/full.md
1---2name: roblox-luau-core3description: Use for Luau language semantics, tables, control flow, string patterns, scope, closures, and cross-language translation errors.4---56# Luau Core Language78## When to Load910Load for pure Luau syntax and semantics: truthiness, tables, iteration, functions, scope, operators, string patterns, and ports from JavaScript or Python. Use `roblox-luau-types` for type annotations, `roblox-luau-patterns` for ownership and lifecycle, and domain skills for Roblox APIs.1112## Quick Reference1314- Only `false` and `nil` are falsy. `0`, `""`, and `{}` are truthy.15- Equality does not coerce types. `0 == "0"` is false. Inequality is `~=`.16- Array conventions are 1-based. `#array` is meaningful only for a sequence without nil gaps.17- Assigning `nil` removes a table key. Assigning a table copies the reference. `table.clone` is shallow.18- Dictionary iteration order is unspecified. Do not make behavior depend on it.19- Dynamic keys require brackets: `record[field]`. Dot syntax uses a literal identifier.20- Missing arguments become `nil`; extra results and arguments can be discarded by context.21- Prefer an `if` expression over `condition and a or b` when `a` may be `false` or `nil`.22- Local names are scoped from their declaration onward. Forward-declare mutually recursive functions.23- Luau string patterns are not regular expressions. Their syntax and capabilities differ.24- Backtick interpolation and `..` concatenation are both valid. Choose the clearer form; collect many fragments and join once in a hot loop.25- NaN does not equal itself and defeats `<`/`>` comparisons; test with `x ~= x`.26- Binary data uses the `buffer` library: fixed size, 0-based offsets, explicit-width reads/writes. Avoid `buffer.readinteger`/`writeinteger` (stubs only, not released runtime).27- For Base64, hashing, or compression use `EncodingService` (buffers, not strings; JSON still via `HttpService`). Details: see full reference.2829```luau30local label = if enabled then "On" else "Off"31local message = `{name}: {score}`3233local byId: {[number]: string} = {}34byId[userId] = name3536for index, value in values do37 print(index, value)38end39```4041### Translation traps4243- JavaScript `===`, `!==`, `null`, optional chaining, spread, arrow functions, and array methods are not Luau syntax.44- Python `None`, zero-based list assumptions, list comprehensions, exceptions, and implicit tuple behavior do not translate directly.45- `x or fallback` tests truthiness, not only absence. It replaces a valid `false` value.46- `typeof(value)` recognizes Roblox datatypes; `type(value)` reports the underlying Luau type category.4748### Review4950Valid Luau, no nil gaps in sequences, no assumed dictionary order, no accidental aliases, no cross-language syntax, no boolean expressions hiding `false` or `nil`.5152> Detailed language traps and translation examples: [references/full.md](references/full.md)