About Luau
Luau is a gradually typed scripting language derived from Lua 5.1. Roblox uses Luau with its own engine APIs; standalone Luau hosts do not automatically provide those APIs.
- Roblox experiences
- Typed game scripts
- Embedded scripting
- Created by
- Roblox and open-source contributors
- First released
- 2021 · standalone open-source release
- Version / standard
- Continuously developed
Roblox manages its embedded version. Codectionary supports editing and highlighting only; run Roblox examples in Studio.
In the real world
- Roblox: Experience scripting in Roblox Studio
Facts checked 3 October 2026. Links open the sources; examples describe specific products or documented uses.
Syntax
local message: string = "Hello, Luau"
print(message)Examples
Your first Script
Roblox Studio: insert a Script in ServerScriptService, paste this code and press Play. Output shows 12. Changing the second argument changes the result without changing the function.
-- Script in ServerScriptService
local function total(price: number, quantity: number): number
return price * quantity
end
print(total(4, 3)) -- 12Add an engine object
Roblox Studio: a separate Script in ServerScriptService. A blue anchored block appears above the origin. Instance, Vector3, Color3 and workspace come from Roblox, so a standalone Luau interpreter cannot run this example.
local block = Instance.new("Part")
block.Name = "LessonBlock"
block.Size = Vector3.new(4, 1, 4)
block.Position = Vector3.new(0, 5, 0)
block.Color = Color3.fromRGB(65, 120, 220)
block.Anchored = true
block.Parent = workspaceBest practices
- Use Studio Output and Script Analysis together: one shows runtime behaviour, the other catches mistakes before execution.
- Start engine experiments in a new baseplate so you can identify every required object.
- Learn client/server placement before adding remotes or persistent player data.
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
In plain English
Write a small function first. Once its inputs and outputs make sense, connect it to a Roblox object or event. Keeping those steps separate makes it easier to identify whether a mistake belongs to the code, the scene setup or the network boundary.
What you’ll learn
- Recognize language features versus engine APIs.
- Place a server Script and inspect its output.
- Choose the next lesson based on the feature you want to build.
Breaking down the syntax
local- Creates a binding in the current scope.
: number- Describes a value to the static checker; it is not runtime input validation.
Instance.new- Creates a Roblox engine object, not a standalone Luau language value.
How it works
Language
Learn values, tables and functions with small outputs you can predict.
Engine
Choose a script location and connect the code to Instances and events.
Multiplayer
Keep authority on the server and validate requests before changing shared state.
When should I use this?
Start here if you are new to Luau or know Lua but have not worked with Roblox script placement. These examples are edited here and run in Roblox Studio.
Common mistakes
Running an engine example in a language-only host
workspace is provided by Roblox. It does not exist in every Luau host.
Incorrect
print(workspace.Name) -- fails when no Roblox engine is presentCorrected
print("Language-only example")
-- Run workspace examples in Roblox Studio.Compare approaches
- Lua: Choose the Lua reference for ordinary Lua hosts and .lua files.
- Luau: Choose this collection for Luau types and Roblox scripting.
Explore deeper
A focused first collection
These 32 pages cover language fundamentals and a practical Roblox path. They do not cover every engine service. CollectionService, Debris and HttpService are not dedicated topics in this release.
Specifications & further reading
Related Luau documentation
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.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.Script, LocalScript and ModuleScript placement
The same code can behave differently depending on where it runs. These lessons use server Scripts in ServerScriptService and LocalScripts in StarterPlayerScripts or StarterGui. A ModuleScript runs when required. Script RunContext also affects execution, so inspect it when a script appears silent.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.