Module 4 · In Studio · challenge 3 of 3 in this lesson
CombatService exposes beginCharge(player) to record when that player started holding a charge on the server
A test in Studio grades it and prints a pass code.
Open
Level 3, Professional
Challenge
Add a charged swing whose strength the server times.
- Start from
- The game at milestone m06 (download)
- Grade it
- To grade work from an earlier milestone, apply your challenge changes to a checkout based on
m14-ship, which includes the Course Runner. In Studio, press Play, then rungame.ServerScriptService.RunGameTests:Invoke("wrench", "wrench-charge")in the server command bar. Copy the pass code from Output.
Done means
- CombatService exposes beginCharge(player) to record when that player started holding a charge on the server
- CombatService.trySwing(player, origin, direction, charge?) accepts an optional 4th charge argument in seconds, capped at 1.2s
- trySwing returns "rejected" and deals 0 damage if charge > 1.2 or if the player has not held the charge long enough on the server
- A swing with charge = nil deals Config.WRENCH_DAMAGE (34), even right after a rejected charge, so the plain tap and the existing wrench_kill test still work
- A full 1.2s earned charge deals Config.WRENCH_DAMAGE + 16, and a charge below a small minimum (the reference solution uses 0.45s) is rejected
- The swing gap still applies between swings: the test waits 0.5s between the tap and the full-charge swing
- challenges/wrench.luau prints TEST PASS for charge_reject_high, charge_reject_unearned, charge_tap and charge_full