Syntax
local score: number = 0
score += 1Examples
Rewrite a small Lua pattern
These equivalent counters show a Lua-compatible assignment followed by Luau compound assignment. Use the second form in Luau; do not assume an ordinary Lua interpreter accepts it.
local count = 0
count = count + 1 -- familiar Lua form
count += 1 -- Luau form
print(count) -- 2Separate types from values
Standalone Luau or a Script in ServerScriptService. The alias describes the record to the checker. It does not create a runtime object or validate data received from another machine.
type Lesson = { title: string, complete: boolean }
local lesson: Lesson = { title = "Tables", complete = false }
lesson.complete = true
print(lesson.title)Best practices
- Keep .lua and .luau files distinct in projects that contain both languages.
- Roblox does not provide unrestricted operating-system or file access just because another Lua host does.
- Port small modules first and review standard-library differences instead of mechanically renaming files.
At a glance
- Purpose
- Typed scripting and Roblox development
- File extension
- .luau
- Runs in
- Luau host; Roblox engine examples require Roblox Studio
- Usually used with
- Roblox APIs and Studio
Specifications & further reading
Related Luau documentation
Luau and Roblox scripting
Start with Luau values and functions, then use Roblox Studio to connect that code to players, Instances and events. Luau is the language; Roblox supplies the game engine APIs. Codectionary supports editing and highlighting, while these Roblox examples run in Studio.Inference, annotations and strict mode
Luau can infer types from expressions, while annotations document the boundary of a function or record. Strict mode reports more incomplete assumptions. Static checks help authors; runtime checks still protect values received from players or saved storage.Lua Variables & Values
Lua uses local for scoped variables. Its basic value types include nil, boolean, number, string, function, table, thread, and userdata.Variables, values and scope
Use local names for values that belong to a function or block. A nested block can read outer locals, but a new local with the same name shadows the outer binding. nil represents absence; false is an actual boolean value.
Start with Luau values and functions, then use Roblox Studio to connect that code to players, Instances and events. Luau is the language; Roblox supplies the game engine APIs. Codectionary supports editing and highlighting, while these Roblox examples run in Studio.Inference, annotations and strict mode
Luau can infer types from expressions, while annotations document the boundary of a function or record. Strict mode reports more incomplete assumptions. Static checks help authors; runtime checks still protect values received from players or saved storage.Lua Variables & Values
Lua uses local for scoped variables. Its basic value types include nil, boolean, number, string, function, table, thread, and userdata.Variables, values and scope
Use local names for values that belong to a function or block. A nested block can read outer locals, but a new local with the same name shadows the outer binding. nil represents absence; false is an actual boolean value.