Problem with multiple enemy health bars

So I wanted to make an enemy with 3 hp and a health bar above them and I linked the health bar and the enemy together. The health bar will appear when I get close to the enemy as I wanted. Everything works fine until I want to add the same enemy again. When I have 2 enemies at the screen and I damage the other enemy then both enemies health bars show orange (2hp) instead of green (3hp). Also I’m new to gdevelop so I think my events could be simplified.

the event that creates health bars is always triggers. you create 60 healthbar/enemy every second!
learn more about Sub-events.

Thanks but how can I fix this? I tried to add trigger once but it didn’t work

without learning? noway.
difficult to see through your code. I i don’t see exactly how many errors there are in it. next time try to use event groups, comments to be understandable to others. and sub events to better understand your own logic, what you are do!

aniways. I think you want to create health bars with the enemies together. so move the actions wich create healt bars in to the event wich spawns the enemies.

Yeah well I’m here to learn hahah… I already do have groups
but I’ll make sure to add comments and I’ll now try your advice. Thanks!

I just can’t get it to work :weary:

There is a very easy but regorous way. Just make every healthbar, enemy, and enemy variable unique.
Make healthbar within enemy in each frame.
Write code to move frame by one on an event such as collision by bullet.

1 Like

Yeah I know… I concidered it but since this is just my first game and I’m just learning that’s way too much effort for me… Thanks tho!