Variable isn't working

so im currently making a game in MV and I want to make a conditional branch that checks to see if your luck is over a certain amount (so that if you have high enough luck you can find extra money from chests), so I have a little test room made
1661327779961.png

here is what is basically just a switch to activate the variable, I have it so that it sets the variable. then I have a conditional branch which checks to see if your luck is greater than or equal to 50, but when I test it out in game, even if my luck is over 50, it still never says what it's supposed to say when my luck is over 50. this is my first time working with variables so it could just be an honest mistake but from what ive read I seem to be doing everything correctly
1661327939663.png
1661327831003.png
So the eventing itself is correct. But is it actually called? The variable is set ONLY when you talk to the NPC, not automatically.

Game devs usually set the variable right above a Conditional Branch

Code:
<>Set Variable "Airo Luck" to GameData Airo's Luck
<>If Variable "Airo Luck" > 50
  <>...
<>Else
  <>...
<>

By the way, when playtesting, you can always Press F9 and browse through your switches and variables.
to add something else, if you add a variable on top like Aerosys said,
you can do (for test purpose)


variable (x) = GameData (actor) Luck
text = : \v[x] (x being the variable ID)

this is you can see if the variable is correctly readed,
if so, remove the text and make a if condition (as Arosys said).

both correct and incorrect can have a text test purpose.
in top if higher than 50
text: Luck is higher than 50
else
text: Luck is lower than 50
end

if this works correct, you can add your actual code what you want to do.
this is a test to make sure the event is working correctly 🙂
I have it so that it sets the variable.
this is your mistake

control variable NEVER "sets" a variable.
it always loads the value given at that moment into the given variable.
and it will keep that value until manually changed, even if the origin of that value is increased.

for that reason the control variable command should always be just before the conditional where the value is tested.
alright, I figured it out, thanks for the help everyone!

Original thread: https://forums.rpgmakerweb.com/threads/variable-isnt-working.150760/