From Game Editor
The most important part of an HP bar is the bar itself. It is possible to do this several ways, the most common two are through animations and the other through canvas. This will cover animations, as you should be familiar with canvas before attempting to implement it in game.
Animation
The sprite should always be done in this method, as it reduces the amount of work. If you do it this way, then the amount of code required is just one line, for maintaining the bar. The other requires possible over 100 lines.
The important thing to note is that the first frame starts with 0, and it builds up. This way your HP variable will be identical to its animpos.
Managing
Now that the animation is taken care of, making the HP bar show the HP amount is the last step. By now there should be an HP variable in place, if you are using an actor variable and cloned HP bars, than skip ahead. This example will not work with actor variables, only global.
HP_Bar -> DrawActor -> Script Editor
animpos=HP;
HP is the global variable. Notice, since the animation is 11 frames long, the max hp is 10, as the first frame is 0. This still needs to be touched up, as the bar will flicker. This is due to the animation, which will need to be stopped. To do this, add an create actor event for HP_Bar.
HP_Bar -> CreateActor -> Script Editor
ChangeAnimationDirection("Event Actor", STOPPED);
This will prevent the animation from running.
Clones
There are several ways to use clones. Tying non cloned enemies makes it harder, but if you are using clones directly tied to a cloned HP bar, than that is still relatively simple. It is even simpler if you use an array to hold the values instead. That way, the clones are tied to enemy health, and the HP bars can access them using cloneindex. The other method would be using Actor*. This page will not go into the use of Actor*, but it is explained here.
This will explain using an array for enemy health. Create an int array, for this example, with 10 ints.
Global Code
int enemHP[10];
This can also be achieved using gameEditor's add variable button. 10 will be the max number of enemies, it can be increased.
Now in the cloned enemies, you can also just use this array for multiple enemy types, all dependent on the game, you would use cloneindex to choose which enemHP to set. The health bars themselves can simply use their cloneindex to determine which HP.
HP_Bar -> DrawActor -> Script Editor
animpos = enemHP[cloneindex];
It is possible to use HP bars, without the use of user created variables. This method would use the HP bar actor and its animpos as the HP holder.