gio
gio

Reputation: 19

Why when i put a variable block into a statement block the value changes from 50,000 to 0?

Im making a cookie clicker game and i have cookie per click upgrades, there is a cost that starts at 50,000 cookies then everytime you buy it, it multipies by 100. But when i put the cost variable into any statement the value changes to 0 for somereason, why?

If i buy an upgrade the cost turns into 0, because of the problem explained above. But when i take the cost variable out of the statement, it goes back to 50,000, why?

my code the cookies per click upgrae cost outside the statement block the cookies per click upgrade cost inside the statement block

Upvotes: 0

Views: 89

Answers (1)

Yanxuan Weng
Yanxuan Weng

Reputation: 59

This is because you cannot put separation characters in variables if you want your variable to be a pure number.

If your variable is 50000 (let's call this var1), and you add a comma to it so it becomes 50,000 (call this var2) Scratch will treat the var2 as not a numerical value!

And so Scratch will handle this by just evaluating 50,000 * 100 to 0.

enter image description here

Upvotes: 1

Related Questions