Codectionary / Developer documentation / Luau

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.

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

Add 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 = workspace

Best 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 present

Corrected

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