A question about Yanfly's tips&tricks video:Phoenix ring

Hi, everyone. I try to make the state that can makes the owner revive after death by Yanfly's Buff & State Core, like Phoenix ring, so I write this JavaScript.

Code:
<Custom Apply Effect>
if (target.isActor()) {
  var i = 111 ;
  if (target.hasState(i)) {
    target.discardState(i);
    target.startAnimation(42);
    var hp = Math.floor(target.mhp * 0.1);
    target.gainHp(hp);
    target.startDamagePopup();
  }
}
</Custom Apply Effect>

But, the effect didn't happen, my character died.
Where the wrong is? Please, can someone tell me?
It should be "target.isStateAffected(i)", not "target.hasState(i)". And to remove state, you should use "target.removeState(i)", not "target.discardState(i)".
It should be "target.isStateAffected(i)", not "target.hasState(i)". And to remove state, you should use "target.removeState(i)", not "target.discardState(i)".

Thanks, it really helps me.
But it doesn't show the animation.
Fortunately, it's not a big problem.

By the way, can it effect on an enemy?
I change "if (target.isActor())" to "if (target.isEnemy())", but it doesn't work.

Original thread: https://forums.rpgmakerweb.com/threads/a-question-about-yanflys-tips-tricks-video-phoenix-ring.88641/