MV Temporary defense state

Hi, I'm trying to make a state that reduces damage by however many stacks it has (using yanfly's buffs & states core among other yanfly plugins). I wrote out the notetags and it looks like it should for all intents and purposes work, and yet I keep getting an error when processing the damage and it completely confounds me.

Skill notetags:
<After Eval>
user.addState(6)
user.tempDef = user.tempDef || 0;
user.tempDef += 1;
user.setStateCounter(6, user.tempDef)
</After Eval>

State notetags:
<Custom React Effect>
if (this.isHpEffect && value > 0) {
value -= user.tempDef;
}
</Custom React Effect>

using the skill correctly gives 1 stack per use, and the stacks are displayed correctly and all

yet when an attack lands, I just get an error. I'm really not sure what I'm doing wrong here?
1772545194912.png
I just get an error
your actor's hp became NaN and the game crashed trying to represent that on a gauge

what I'm doing wrong here?
the user in a <custom react effect> is the user of the action. the target is the one being acted on. youve used user.tempDef in the react effect, but the user (attacker) doesnt have that property. you want target.tempDef
your actor's hp became NaN and the game crashed trying to represent that on a gauge


the user in a <custom react effect> is the user of the action. the target is the one being acted on. youve used user.tempDef in the react effect, but the user (attacker) doesnt have that property. you want target.tempDef
ohhhhhh word. Thanks!

Original thread: https://forums.rpgmakerweb.com/threads/temporary-defense-state.182714/