I am trying to create a skill which triggers a Common Event that checks through a Conditional Branch if the enemy is affected by a certain state

Hello everybody, my issue currently is trying to make a Skill that when used Heals the User if the enemy is affected by a certain state upon hit by such Skill.

So first, I added a Common Event inside such Skill, went to the Conditional Branches options, went to 3rd page where u find "Enemy 1# ?" Appeared or State, and then i placed the state.
I attempted to fill the entire Common Event with the same Conditional Branch over and over just changing the Enemy part (enemy 1#, enemy 2#, enemy 3#)

Because my Skill hits all enemies so i wanted a Conditional Branch that could say "hum, this enemy is affected by this state" so it would trigger a healing.
What happens is that, it doesnt seem to recognize the target.

And i attempted to fix this by using Javascript on the Conditional Branch with enemy.isStateAffected(x), but i dont know much about it, and everytime I tested the skill it would show me "Cannot read property 'isStateAffected' of undefined.
If anybody could help me, tysm in advance

Edit: I figured it out!
I would think you'd put that into your damage formula instead of a common event. Or in an action sequence if you do those.
Your original solution should work. Show screenshots so people can help you.
(When using scripts, you don't use 'enemy', but you need a reference to the battler object.)

edit: or did you mean that you can't get the target for the healing in your common event? You can put in your variables 'last actor id to act' and use that.

Original thread: https://forums.rpgmakerweb.com/threads/i-am-trying-to-create-a-skill-which-triggers-a-common-event-that-checks-through-a-conditional-branch-if-the-enemy-is-affected-by-a-certain-state.176364/