Variable Cost - Resets Variable Value?

So I'm really confused. I have the YEP Skill_Core and Core_Engine. I saw someone post a thread back in 2018 similar to this problem I'm having, but my issue is a bit different.

I copied the code to try and use it for my variable. The variable I use progressively gets higher every second as I walk around or perform turns in battle and I want the skill to use this variable as the cost. However when I try this code, in the menu it displays the cost correctly, but when I look at it in the skills menu (Overworld or in battle), it instantly decreases the variable down no matter if I use it or not.

I don't understand what's wrong with the code. So here's the basic gist of what I want it to do:

Blood Strike
Costs 50 Blood
VariableID for blood is 1

<Custom Requirement>
if ($gameVariables.setValue(1) >= 50)
{
value = true;
} else {
value = false;
}
</Custom Requirement>

<Custom Execution>
$gameVariables.value(1,$gameVariables.value(1) - 50);
</Custom Execution>

<Cost Display Eval>
var variableId = 1;
var value = 50;
$gameVariables.setValue(variableId, value);
</Cost Display Eval>

<Custom Cost Display>
\c[30]\v[1]\c[30] Blood
</Custom Cost Display>
I think you have a few things switched around.
Spoiler: First
First, the custom requirement doesn't need to use $gameVariables.setValue() because that function is used to set the value of a variable. Instead use $gameVariables.value() to check the value of the variable.

<Custom Requirement>
if ($gameVariables.value(1) >= 50)
{
value = true;
} else {
value = false;
}
</Custom Requirement>
Spoiler: Second
Second, the custom execution is where you need to handle the changing on the variable value because this is the code that's executed when you use the skill. Here is where you want to use $gameVariable.setValue();

<Custom Execution>
$gameVariables.setValue(1, $gameVariables.value(1) - 50);
</Custom Execution>
Spoiler: Third
Now, here's another problem I almost missed,
The Cost Display Eval is setting the value of Variable 1 back to 50. This wouldn't be an issue but you're using the same variable for requirement. If the cost of the skill never changes, simply use the cost value in the custom cost display. If you want a dynamic cost based on the value of a variable, you'll need to use a separate variable. You can completely remove the Cost Display Eval if you're not planning on using a dynamic cost.

<Cost Display Eval>
var variableId = 1;
var value = 50;
$gameVariables.setValue(variableId, value);
</Cost Display Eval>


Simply exchange the variable 1 text code with the static cost of the skill, if the cost is always 50
<Custom Cost Display>
\c[30]50\c[30] Blood
</Custom Cost Display>

Let me know if this works for you.
I think you have a few things switched around.
Spoiler: First
First, the custom requirement doesn't need to use $gameVariables.setValue() because that function is used to set the value of a variable. Instead use $gameVariables.value() to check the value of the variable.

<Custom Requirement>
if ($gameVariables.value(1) >= 50)
{
value = true;
} else {
value = false;
}
</Custom Requirement>
Spoiler: Second
Second, the custom execution is where you need to handle the changing on the variable value because this is the code that's executed when you use the skill. Here is where you want to use $gameVariable.setValue();

<Custom Execution>
$gameVariables.setValue(1, $gameVariables.value(1) - 50);
</Custom Execution>
Spoiler: Third
Now, here's another problem I almost missed,
The Cost Display Eval is setting the value of Variable 1 back to 50. This wouldn't be an issue but you're using the same variable for requirement. If the cost of the skill never changes, simply use the cost value in the custom cost display. If you want a dynamic cost based on the value of a variable, you'll need to use a separate variable. You can completely remove the Cost Display Eval if you're not planning on using a dynamic cost.

<Cost Display Eval>
var variableId = 1;
var value = 50;
$gameVariables.setValue(variableId, value);
</Cost Display Eval>


Simply exchange the variable 1 text code with the static cost of the skill, if the cost is always 50
<Custom Cost Display>
\c[30]50\c[30] Blood
</Custom Cost Display>

Let me know if this works for you.
Ah that worked better! So the problem was my eval part of the code mostly. Thank you!
So the problem was my eval part of the code mostly.
Honestly, if you would have just fixed the eval portion, it still wouldn't have worked rhe way you'd been wanting it to.

Original thread: https://forums.rpgmakerweb.com/threads/variable-cost-resets-variable-value.144300/