Untargetable State Script Problem

I'm using the Untargetable state script by Hime, and whenever I apply the state no matter which battler I assign it to, I can't
target the rightmost enemy. Even if that enemy isn't the one with the state assigned to it, and then the enemy that does have the state assigned to it will be targetable, but invincible. In that, I can select a skill and in the battle log it will say "X used Attack!" but the animation won't play and no damage will be applied.

pic1.PNG
pic2.PNG
pic3.PNG

Now, If I make the enemy assigned with the untargetable state the rightmost enemy, the game will crash after defeating the other two enemies and when I click to attack the remaining enemy. (The state should be removed at this point)
pic 4.PNG


-Thanks
Moved to: RGSS Script Support

Original thread: https://forums.rpgmakerweb.com/threads/untargetable-state-script-problem.112071/