โ ๐ Lua World
๐ Speed Boost Pad
You can practise without a player, but pick a player to score points!
๐ The mission
Today you unlock
If statements choose a path
An if statement checks a condition and chooses which answer to return. Order matters: check the special cases first.
๐ก Hint ladder
- if hasBoost then ... else ... end
- You can test a boolean directly: if hasBoost then โ no == true needed.
๐งช Coach checks
- โฏ boosted 16
- โฏ no boost
- โฏ boosted 25
- โฏ slow no boost
Live coach
Getting ready
โโโ
๐ฌ You can test a true/false value directly: if hasKey then ...
function openChest(hasKey)
if hasKey then
return "Treasure!"
else
return "Locked..."
end
end
print(openChest(true)) -- Treasure!
print(openChest(false)) -- Locked...
๐ It printed:
Nice โ you saw it work!
๐ Output
๐งฉ Gaps filled! Ready to write it all yourself?