Odd Text Conversion Behavior

I’m working on updating the UI after the player’s turn. I’m trying to take their current score and add the new score but when I add the 2 together I get 1. When I attach the debugger I can see that I’m getting the text and the current points.

Right now the player has 1200 points.

That gets converted to a string and you can see the value is still correct, 1200 points.

Finally when the string is converted to an int, the value becomes 1. So instead of adding the newly scored points to their current point value of 1200, its adding the newly scored points to 1.

At the start of the game when the player has 0 points, this works fine. Anyone know what exactly is going on or anything to check that might be causing this behavior?

This conversions looks weird. I’m even not sure that it must work correctly.

You converting 1,200, not 1200? Maybe this comma produce this bug, if its but at all.

Why don’t you make all calculations with integers/floats and convert it to text only when output to screen?

What redbox said is correct, the string->int conversion won’t handle pretty printed strings, and that is expected behaviour.

What you’re doing is really weird though. It would be better to store and manipulate the score as an int, and then convert it to text for display.

Had the same problem, how do I fix that?