MV Stealth state

I created a state which applies 0 opacity and applies <cannot select> using yanfly selection control. What I want is that the user who is in the stealth state should only be able to apply states to allies and themselves plus healing. The moment the user decides to attack they should leave the stealth state. I tried using this piece of code within the state but it's not working.
Code:
<custom respond effect>
user.removeState(45);
</custom respond effect>

I've searched many places for "remove state after attacking"but I can't find anything solid. Thank you.
<Custom Confirm Effect>
if (this.isHpEffect() && value > 0) {
user.removeState(stateId);
}
</Custom Confirm Effect>

try putting this in the state.
just removed a couple lines from a "charge" state someone else helped me make before
I've made a stealth state that uses Yanfly's battle core engine, yanfly's selection plugin, and yanfly's buff state core.

In the skill that applies the stealth state you put.

Code:
<Setup Action>
opacity target: 0%
</Setup Action>

Then in the stealth state you put.

Code:
<Cannot Select: All>
<Custom Confirm Effect>
if (this.isHpEffect() && value > 0) {
user.removeState(45);
}
</Custom Confirm Effect>

<Custom Remove Effect>
target.spriteOpacity(255,0)
</Custom Remove Effect>

Make sure to put the stealth state in user.removeState(x)

Original thread: https://forums.rpgmakerweb.com/threads/stealth-state.126227/