Tutorials•October 6, 2026•5 min read

Roblox True and False Scripts: Luau Booleans Explained

Learn true, false, not, and, and or in Roblox Luau. Includes a predictable toggle exercise, truthiness checks, and common BoolValue mistakes.

In Roblox Luau, true and false are boolean values. Use them to represent a condition such as whether a round is active or a door is open. They are lower-case keywords without quotes. "false" is text, not a false boolean.

False waits for a round while true selects the active-round branch
Original boolean decision diagram, not a Studio screenshot.

Run your first boolean check

Insert a normal Script in ServerScriptService with default Legacy RunContext. Open Output and start a Studio play test.

local roundActive = false
print(roundActive) -- false

if roundActive then
  print("Round is active")
else
  print("Waiting for the next round")
end

The expected message is “Waiting for the next round.” Change the initial value to true and run a new test. Predict which branch should execute before checking Output. This practice makes an if statement concrete without requiring a full round system.

Toggle a boolean with not

not negates truthiness. For a boolean variable, it flips true to false and false to true.

local doorOpen = false
for attempt = 1, 4 do
  doorOpen = not doorOpen
  print(attempt, doorOpen)
end

Expected states are true, false, true, false. This example only changes a variable. It does not create a door or change a Part’s collision. Connect state to visible behavior as a separate step after the simple sequence is understood.

Only false and nil are falsey

Luau treats only false and nil as falsey in a condition. Zero, an empty string, and the string “false” are truthy. The official Luau library reference describes truthy checks.

What an if condition sees
ValueBranchCommon mistake
falseElseNone: this is a boolean
nilElseConfusing missing data with an intentional false
0ThenAssuming zero means false
""ThenAssuming empty text means false
"false"ThenPutting quotes around a boolean keyword

If you want to check a number, write the actual comparison: coins > 0. If you need non-empty text, check its length or compare it to an empty string. Do not rely on a general truthy check to express those different questions.

Combine conditions with and and or

For boolean operands, and requires both conditions to be true; or accepts either. Name the conditions so the rule is readable.

local roundActive = true
local playerAlive = false
local canAct = roundActive and playerAlive
print(canAct) -- false

local hasKey = false
local doorUnlocked = true
local canEnter = hasKey or doorUnlocked
print(canEnter) -- true

More generally, and and or return operands rather than always converting their result to a boolean. For example, nil or "Fallback" returns the fallback string. Keep default-value expressions separate from rules that are intended to produce a true/false result.

Avoid the false-value fallback trap

An expression like condition and value or fallback chooses the fallback when value is false or nil, even if condition is true. Luau provides an explicit if expression for that case; its lint documentation explains the misleading and/or pattern.

local hasSavedSetting = true
local savedSetting = false
local setting = if hasSavedSetting then savedSetting else true
print(setting) -- false

This preserves the player’s intentional false setting. Using savedSetting or true would replace it with true.

BoolValue is an object with a Value property

A BoolValue instance stores a boolean in its Value property. The object itself is not the stored boolean. After finding the intended BoolValue, read flag.Value when checking its state. An existing object used directly in an if condition is truthy regardless of whether its Value is false.

Also handle the case where the object is missing before accessing Value. For a shared gameplay feature, define which server system owns and changes the state. A client-supplied flag is not sufficient proof that a purchase, reward, or permission is valid.

Debug one condition at a time

  • Print both the value and its type when a branch surprises you.
  • Check whether quotes turned a boolean into text.
  • Check whether you tested an object instead of its Value.
  • Separate missing data from an intentional false value.
  • Test every combination when joining two boolean conditions.

Continue with the practical scripting tutorial for events and state, or use Find All to locate assignments that change a flag. These snippets teach language behavior; they are not complete persistent settings or authorization systems.

Frequently Asked Questions

Is the string false the same as false in Roblox?▾

No. false without quotes is a boolean. The text string "false" is truthy in a Luau condition.

How do I switch true to false?▾

For a boolean variable, assign its negation: flag = not flag. Repeating the operation alternates between true and false.

Does zero count as false in Luau?▾

No. Only false and nil are falsey. Use an explicit comparison when checking a numeric condition.

Ready to build your Roblox game?

Describe a small prototype, review the generated project, and test it in Roblox Studio before publishing.

Try Obby Free →