I have 2 different scores due to the player picking 2 different items. I have added an ending scene where the “total” text should display the addition of these 2 scores.
The code that i have inputed:
Change the text of total: set to ToString(ToNumber(GlobalVariable(SCORE_ORANGE))) + ToString(ToNumber(GlobalVariable(SCORE_YELLOW)))
Instead this is the error it gives me:
“You tried to use an expression that returns a number, but a string is expected. Use “ToString” if you need to convert a number to a string”
Hi,
you don’t need all these long expressions any more, since the variable system has been changed a while ago. After declaring the variables in the variable menu, you can just call them in the events by their name.
You can just write the variable names without any other expression but then their values are interpreted as strings and displayed together. With the ToString-expression the values of both variables will be interpreted as numbers first, added and the total value displayed.
You have additional rounded brackets just before and after the “+” sign. As a result, you are creating a string out of score_orange, and appending score_yellow to it:
@Drona’s action add the two scores before converting the result to a string: