Answered Plainly
Display: Text size:

Luau Basics 1: Variables, Numbers, and Words

The short answer: A variable is a name that holds a value — like a labeled box. In Luau you make one with the word local, and the value inside can be a number, a string (text), a boolean (true or false), or nil (nothing there yet). Every example on this page was test-run before the page was written, and the output shown is the output it really produced. Paste any example into a Script in Roblox Studio and you will see the same thing in the Output window.

Variables: labeled boxes

Roblox's own language guide puts it in one line: a variable is a name that holds a value. You create one by putting the variable on the left of an = sign and the value on the right.

Almost every variable you write should start with local. A local variable belongs to your script, and Luau actually reads locals faster than globals — Roblox's guide says locals are almost always the better choice. Two naming habits from the same guide: names are case-sensitive (Coins and coins are different boxes), and it is best to spell words out fully and use camelCase for local variables — playerCoins, not pc.

The four beginner types

local playerName = "Alex"
local coins = 25
local hasKey = true
local mystery

print(playerName)
print(coins)
print(hasKey)
print(mystery)
print(type(playerName))
print(type(coins))
print(type(hasKey))
print(type(mystery))

What you should see:

Alex 25 true nil string number boolean nil

Doing math

local coinJar = 10
coinJar = coinJar + 5
print(coinJar)
coinJar += 10
print(coinJar)
print(7 * 3)
print(7 / 2)
print(10 % 3)
print(2 ^ 10)

What you should see:

15 25 21 3.5 1 1024

Putting words together

Two dots, .., glue strings together. It is called concatenation. The glue adds no space by itself — if you want a space, it has to be in one of the strings.

local firstWord = "Hello"
local secondWord = "world!"
print(firstWord .. " " .. secondWord)
local visitorName = "Alex"
print(`Welcome back, {visitorName}!`)
print("Coins: " .. 25)

What you should see:

Hello world! Welcome back, Alex! Coins: 25

Comments: notes Luau ignores

Anything after two dashes, --, is a comment — a note for humans that Luau skips completely. A long comment that covers many lines starts with --[[ and ends with ]]. Good comments explain why, so future-you can follow the code.

-- Luau skips anything after two dashes.
local speed = 16 -- This note sits at the end of a line.
--[[
This is a long comment.
It can cover many lines.
]]
print(speed)

What you should see: just 16. The comments change nothing — they are only there for the reader.

Try it in Studio: open the script from page 2 of this series, delete its contents, and paste any example from this page in its place. Run the game and compare your Output window with the "What you should see" box. Matching output means your code ran exactly as written.

Sources (official only; read in full November 7, 2026):

Every code example on this page was run on a Luau interpreter before this page was written, and the outputs shown are the outputs the runs produced. Checked November 7, 2026.