Decisions, lesson 6
Booleans and comparisons
Goal: Ask yes or no questions about values.
about 4 min3 practice exercises
A boolean is a value that is either true or false. Games are full of them: is the gate open, does the player have enough coins, is the round over.
You usually get a boolean by comparing two values:
local coins = 10
print(coins == 10) -- true (equal to)
print(coins ~= 10) -- false (not equal to)
print(coins > 10) -- false (greater than)
print(coins >= 10) -- true (greater than or equal to)
print(coins < 25) -- true
Watch two things:
==compares. A single=assigns. Mixing them up is the most common beginner error.- "Not equal" is
~=in Luau, not!=.
You can store the result like any value:
local canOpenGate = coins >= 10
print(canOpenGate) -- true
Sources
Checked against Roblox's documentation on . The lesson is in our own words; these pages are the source of truth.