Codectionary / Developer documentation / Luau

Lua vs Luau

Luau grew from Lua 5.1 and adds its own syntax and type checking. It is not another name for the latest Lua release. Check both the language and the host APIs before moving a Lua script into Roblox.

Syntax

local score: number = 0
score += 1

Examples

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)     -- 2

Separate 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