Module 10 · In Studio · challenge 3 of 3 in this lesson

trySpend buys with an exact balance and refuses zero and negative amounts

A test in Studio grades it and prints a pass code.

Open

Level 3, Professional

Challenge

Fix the three rules in challenges/unit_tests_work.luau on m14-ship. Press Play and run this in the server command bar:

luau
game.ServerScriptService.RunGameTests:Invoke("unit-tests")
Start from
The game at milestone m14 (download)
Grade it
In Studio, press Play, then run game.ServerScriptService.RunGameTests:Invoke("unit-tests") in the server command bar. Copy the pass code from Output.

Done means

  • trySpend buys with an exact balance and refuses zero and negative amounts
  • healthAfterHits uses the hit count and never goes below 0
  • nextPhase sends Cooldown to Idle and ignores events that do not apply
  • challenges/unit-tests.luau prints TEST PASS for all thirteen cases

The Course Runner prints this code when the test passes.