Need help with setting a variable based off of damage done

Hey, hope this is the right board, I'm working with RPG Maker MZ. What I'm trying to do is make it so that when a party member attacks something, they gain EXP based off of how much damage they deal.

I appreciate suggestions, but what I'd specifically want to know is: how would I make it so that attacking would set a variable to however much damage the party member just dealt?

Appreciate the assistance.
The easiest way is to use a plugin that can access the damage dealt directly. You can use my Eval Tags plugin, or if you're already using VisuStella products you'd use their Battle Core.

Using my Eval Tags, you'd give the actor the notetag
Code:
<Action Damaged Eval>
user.gainExp(Math.round(value/2));
</Action Damaged Eval>
That will gain half of the damage dealt as experience.

If there's some reason you actually need to set a variable instead, the script call is $gameVariables.setValue(ID, amount)

Original thread: https://forums.rpgmakerweb.com/threads/need-help-with-setting-a-variable-based-off-of-damage-done.168944/