Use the "On Destroyed" condition on the bullet. Add 1 to the global variable when a bullet is destroyed. And when a bullet hits a target, reset the global variable to 0.
Make sure you destroy the bullets when they hit a target, wall, or are outside of the layout.