Help! "For Each" not working!

In my game, my character shoots bullets. I want to make things in the game that increase the firerate of his bullets. He will only shoot bullets when his shooting animation is at a certain frame, so to increase his firerate, I made events that speed up the shooting animation. When the bullets hit an enemy, each bullet will do damage because of a variable.
However, for some reason it isn’t working.
My code is:

“Repeat for Each Bullet”
Condition: Bullet is in collision with enemy + Trigger Once
Action: Do - GlobalVariable(Damage) to variable Health of Enemy.

I have the events for deleting bullets in the player’s external event as well as the Damage global variable.

I want each bullet that hits the enemy to damage it, but if the firerate is too high, I will be shooting millions of bullets at the enemy, and it won’t die (The enemy’s health is 5 btw).

For some reason, the “For Each” tool is not working like it should.
Am I doing something wrong? Any help is appreciated. Thanks in advance.

is hard to tell without seeing the resl events. Maybe you check enemy health=0 ? if you do try <0
You can post your code if you want

The code is underneath test enemy.

Try removing the sub-event and moving the action to that main event.

Also, “Repeat for each object” condition is not necessary since the conditions are automatically checked for each instance of the object.

Okay, I did what you said, but nothing changed. The same thing as before is happening. :frowning:

This is how I did it in my game. It deletes the bullet as soon as it collides with the enemy. So no need of using the “Trigger Once” condition as well. You can try this way.

Note: In this screenshot, Variable hit of Enemy was initialized as 0.

Apparently, deleting the bullet works. I had an animation for my bullets in which they explode when they collide with something. Maybe I’ll make the explosion a separate object because that was the problem. Thanks for the help mate!

1 Like

Glad I could help :slight_smile: