How would i make a hp bar for enemys so you have to hit them?

How would I make a enemy get hit a certain amount of times before boing deafeted and how would I do the vice versa?

It looks like this was discussed before here -> http://forum.flowlab.io/discussion/13/how-to-create-health-plus-bar