Codectionary / Developer documentation / 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.

Related languages, different targets

Lua began at PUC-Rio in 1993 as a small embeddable scripting language. Luau grew from Lua 5.1 for Roblox and is now developed as an open-source language with its own runtime and tools. Familiar local variables, tables, functions and control flow make the transition approachable, but the languages have diverged.

A plain Lua program normally runs under a version-matched Lua interpreter or an application embedding Lua. A Luau program runs in Roblox or another Luau host. The host matters: Roblox APIs such as game and workspace are absent from the standalone Luau CLI and ordinary Lua.

Lua and Luau at a glance

Use this comparison as a choice of language and runtime, not a promise that a script can move unchanged between them. Even code using shared syntax may rely on a host library that is unavailable elsewhere.

QuestionLuaLuau
OriginCreated at PUC-Rio; first released in 1993.Derived from Lua 5.1 for Roblox; developed separately.
SyntaxCore Lua syntax depends on the installed release.Shares much Lua 5.1 syntax; adds Luau syntax such as += and type annotations.
Type checkingDynamic typing; standard Lua has no built-in gradual type checker.Optional annotations, inference and luau-analyze or Studio type diagnostics.
Typical useEmbedded scripting, application extensions and standalone scripts.Roblox experiences and other applications embedding Luau.
Runtimelua or an application embedding a particular Lua version.luau CLI or a Luau host such as Roblox; Roblox APIs require Roblox.
CompatibilityNewer Lua syntax and libraries may not exist in Luau.Luau additions and host APIs may not run in ordinary Lua.

Read the small code difference

Both languages can increment a local counter with count = count + 1. Luau also accepts count += 1, which ordinary Lua does not. A Luau annotation such as value: number helps static tools report mismatched uses before running code; it is removed from runtime values and does not validate a network message by itself.

For porting, test the specific Lua release, Luau syntax and library calls, not just the filename. Luau’s compatibility guide lists differences in its standard library, including removed file and package APIs in its sandbox. A Roblox script also needs the appropriate engine objects and execution context.

Which should you learn?

Choose Lua when the application you want to extend embeds standard Lua, or when you want to learn the standalone language and its common libraries. Choose Luau when your goal is Roblox or a project explicitly using the Luau runtime. The shared foundations transfer, but check each host’s API and version documentation before moving code.

In Codectionary’s Playground, both languages are editing-only. Use local lua for Lua, standalone luau for language-only Luau, and Roblox Studio for engine scripts.

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.

Runtime & versions

Luau host; Roblox engine examples require Roblox Studio. Feature availability depends on the language and runtime version used by your project; consult the official reference below.

Luau documentation

Specifications & further reading