Count the hits

Try itStart your game

This slime keeps count. Every time it is hit, it adds 1 to @hits and tells you the number.

​

Hit the slime

  1. Press Play Play this script and click the little game.
  2. Walk the hero up to the slime. Stop about one block away.
  3. Press X to swing the sword.
  4. Swing again, and again.

"That is 1!" "That is 2!" "That is 3!" The slime remembers, because the number is in the box.

This slime takes 5 hits to beat, so you can count all the way to 4 before it goes.

How it works

LineWhat it does
@hits is 0Starts the count at 0.
@hits goes up by 1Adds 1, each time the slime is hit.
say "That is @hits!"Says the words, with the number from the box in place of @hits.

Now in your own game

Press Open your game here, in the builder below, and give your enemy this script. One thing is different there: a plain enemy is beaten by one hit, so it never gets to count.

To make yours tougher, open its settings, turn on Boss, and set Hits to defeat to 5.

This makes a new game in your Lab and opens the builder right here. It is free.

This section ticks itself when you press Play Play this script.

Press Play in the code box to finish this section.