Hunt down real bugs in variables, conditionals, loops, and functions — and type the one-line fixes.
You know the tools now — variables, functions, conditionals, loops, events. Bugs in this section are rarely big. They're one character: a missing local, a single = where you meant ==, a task.wait that never got written. This lesson is a training ground for exactly those.
coins = 0
Add the missing declaration so the variable stays local.
if coins = 5 then
Type the corrected line so the comparison works.
Press Play and your game freezes instantly. Output shows no error — the game is stuck inside a loop that never ends and never breathes.
while true do
print("tick")
end
Write the line that pauses the loop so the game doesn't freeze.
function addCoins(amount)
coins = coins + amount
end
addCoins()
Write the corrected call that passes the amount.
A coin counter never changes. Spot the bug in the snippet and type the fixed line.
local coins = 0
coins == coins + 1
Type the corrected line so the counter actually counts.
One last hunt, but this time you assemble it. Arrange the lines so a part's click gives the player a coin each time — no imposters.