The easiest way to link three objects together is to use a container. That way, you won’t need the ID variables — picking one instance (like the hitbox) in events will automatically pick the other two objects in the same container.
Another option is to use a hierarchy, with one object as the parent and the others as children. Then you can use "Pick parent" and "Pick children" conditions. Hierarchies also let you move all the objects as one unit.
You can even combine both approaches: container+hierarchy for ultimate flexibility!
.
The way you organize your events is pretty inefficient. Running a For Each loop on every tick and nesting everything inside it (even triggers) will hurt performance, especially with many enemies. Triggers should generally not be placed inside other events.
Never use "Trigger once" condition with objects that have multiple instances or inside loops - it only leads to bugs that are hard to debug.
Finally, you need to tell the DEATH function which enemy instance to destroy, otherwise it may destroy the wrong enemy. Add a parameter EnemyUID, and pass enemy.UID in this parameter when calling the function.
So the correct code should look like this:
// Parent event
Player on collision with Enemy
Player is not dead yet
... // sub-events
... Player is immune -> Call function ENEMY_DEATH(Enemy.UID)
... Else -> kill the player