โ ๐ Lua World
๐ Obby Score
You can practise without a player, but pick a player to score points!
๐ The mission
Today you unlock
Functions return answers
A function is a tiny machine: it receives inputs, works something out, then returns one answer for the tests to check.
๐ก Hint ladder
- checkpoints * 100 - deaths * 10
- Wrap it in math.max(..., 0) so it cannot go negative.
๐งช Coach checks
- โฏ 5 checkpoints 3 deaths
- โฏ flawless run
- โฏ died a LOT
- โฏ never started
Live coach
Getting ready
โโโ
๐ฌ Combine multiply, subtract and math.max โ like a real game score system.
function quizScore(right, wrong) local score = right * 10 - wrong * 5 return math.max(score, 0) end print(quizScore(8, 2)) -- 70 print(quizScore(1, 10)) -- 0
๐ It printed:
Nice โ you saw it work!
๐ Output
๐งฉ Gaps filled! Ready to write it all yourself?