Variable numeric counter not working

Twine Version: 2.3.5
Story Format: Sugarcube 2.30.0

I’m writing a story where the player interacts with characters via relationship points (RP) that go up by 1 each time the player makes the right decision. I declared all my variables in the second page of the game (which is the tutorial). I declared all RP values like this:

<<set $carlyrp to 0>>

As the game goes on, the players makes a couple of decisions that add RP to Carly. When that decision is made, this happens:

<<set $carlyrp to $carlyrp + 1>>

Then we reach a point where Carly’s reaction to the player’s decision is dependent on how many RP the player has with her. Before I wrote this, I wanted to make sure that this counter was working, so I simply typed:

<<print $carlyrp>>

And nothing was actually printed. To better test this out, I made a more specific test. I wrote this:

<<if $carlyrp is 2>>hello

At this point in the story, I’m only ever testing if the RP value is 2, as those are the amount of points available. When I run the game, make both decisions that grant me the RP value of 2, this if statement actually prints bye instead of hello. I’m not sure why my counter isn’t working properly. Obviously, it should be printing hello.

[quote=“ComradeMaethor, post:1, topic:44789”]I declared all my variables in the second page of the game (which is the tutorial)

And nothing was actually printed.
During that testing play-through did you visit the Passage containing the <<set $carlyrp to 0>> macro call before visiting the Passage that contained the <<print>> macro?

note: Generally $variables like the one you are describing are best initialised within your project’s StoryInit special passage, because that passage is guaranteed to be processed before each play-through.

Oh yeah, I should’ve known that the variable actually has to be declared by the game first before I test the variable.