Yanfly's Buffs and States Core (Damage when state expires)

Hello, everyone!

I'm making a skill that applies a state to the selected enemy. Once the state expires, it should damage the enemy, and if a critical strike lands, it should do that dmg. The thing is that it seems that I'm ignoring something in the formula in the state's notetag. It looks like this:

<Custom Leave Effect>

user.startAnimation(14);

user.gainHp((a.mat - b.mdf));

</Custom Leave Effect>


It looks like this, but I don't know what I'm doing wrong. Also, how can I check if a critical strike lands and apply that dmg?

Thanks!!!
a few things to check first
A. is there any errors in the console. you can check this by hitting f8 on your keyboard
B. what version of RPG Maker are you on. I hav seen people in the past have problem with BuffStatesCore in the past and that was the solution.(Do not that game version and editor version are two different things)

Original thread: https://forums.rpgmakerweb.com/threads/yanflys-buffs-and-states-core-damage-when-state-expires.89045/