[solved]Problem with setting a variable, using Yanfly skill core

Okay, so my skill is designed to do random elemental damage to the enemies it targets. I'm having an issue with the variable getting set prior to the first use of the skill. The first time the skill is used it does not show the animation that I've assigned and is not doing the force element command within whole action, it is just doing the damage calculation in the damage formula box. After the first use, however, the skill works as intended.

Here is the note tag for the skill. Plugins involved are Yanfly Battle Core, Action sequences, element core, and skill core.
Code:
<Pre-Damage Eval>
$gameVariables.setValue(21, Math.randomInt(4) + 1)
</Pre-Damage Eval>
<whole action>
if $gameVariables.value(21) === 1
  // Change to Fire element
  force element: 2
  animation 36: targets
else if $gameVariables.value(21) === 2
  // Change to Water element
  force element: 3
  animation 34: targets
else if $gameVariables.value(21) === 3
  // Change to Air element
  force element: 4
  animation 40: targets
else if $gameVariables.value(21) === 4
  // Change to Earth element
  force element: 5
  animation 38: targets

end
action effect
clear element
wait for animation
</whole action>
<target action>
</target action>

I believe the issue is with the skill core note tag. Currently it is set to Pre-Damage Eval, but I've also tried Before Eval and it did not make a difference.

My work around is an autorun event that sets the variable with a script call and erases itself. However, if anyone knows why this is not working the first time the skill is used, I would like to understand. Thank you.
Try "Custom Execution",.. Im using no SV battles mostly (on TacticalBasedStrategy- projects) and Custom Execution triggers earlier than the other Evals for my usage..
..you could also use Huds(=srd Huds for EG) , connected with Switches to every Eval in order to show visually when a eval triggers,that might help for testing purposes..
Custom Execution worked. Thanks a bunch!

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/solved-problem-with-setting-a-variable-using-yanfly-skill-core.124299/