Syntax
local title = `Lesson {3}: Tables`Examples
Build a status label
Standalone Luau or a Script in ServerScriptService. Interpolation keeps the values beside their labels, while string.format gives explicit decimal formatting.
local completed = 3
local total = 8
print(`Completed {completed} of {total}`)
print(string.format("Progress: %.1f%%", completed / total * 100))Distinguish bytes from text
The accented letter occupies more than one UTF-8 byte. utf8.len counts code points, which still need not equal visible grapheme clusters for every string.
local word = "café"
print(#word) -- 5 bytes
print(utf8.len(word)) -- 4 code points
local labels = {"Types", "Tables", "Functions"}
print(table.concat(labels, " / "))Best practices
- Use table.concat for a list of fragments rather than repeatedly rebuilding a large string inside a loop.
- Do not split user-facing Unicode text at arbitrary byte positions.
- Treat player-entered text as untrusted; Roblox user-visible text can require platform filtering beyond string formatting.
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
Tables, arrays and dictionaries
A Luau table can hold a sequence, a dictionary or a record. A sequence uses consecutive integer keys starting at one; named fields describe a record. Type annotations describe the intended shape to the checker, but do not copy tables or validate incoming data at runtime.Functions, optional arguments and returns
Functions group a calculation or action behind a named boundary. Optional types allow nil; they do not supply defaults. Return tuples and variadic arguments are useful when the number of values matters, but named record results are often easier to extend.GUI buttons and user input
Player UI belongs on the client. Use GuiButton.Activated for a button that works across supported input methods, and avoid handling a keyboard shortcut when the interface has already consumed that input. A local UI action can request a server action, but cannot authorize it.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.
A Luau table can hold a sequence, a dictionary or a record. A sequence uses consecutive integer keys starting at one; named fields describe a record. Type annotations describe the intended shape to the checker, but do not copy tables or validate incoming data at runtime.Functions, optional arguments and returns
Functions group a calculation or action behind a named boundary. Optional types allow nil; they do not supply defaults. Return tuples and variadic arguments are useful when the number of values matters, but named record results are often easier to extend.GUI buttons and user input
Player UI belongs on the client. Use GuiButton.Activated for a button that works across supported input methods, and avoid handling a keyboard shortcut when the interface has already consumed that input. A local UI action can request a server action, but cannot authorize it.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.