Hi, how do I stop the numbers from duplicating whenever I pick up coins?
The problem is that text objects are strings, not numbers or counters. So when its a text object, 2+2 isnt 4, its literally 22. I suggest you create a variable named coins and do the same thing except just to the variable, and in another event, give it no condition (or, keep it in the same spot under each coin event) that then sets the counter to the total amount of coins.
Oh I see, I will try that thanks
No luck, I tried to do it but the closest I got is that it works, but when I pick up a different coin it updates to that one and forgets the bronze or gold coin from earlier I picked up refreshing the score of THAT specific coin instead. I want all the coins to be added together. Here is the closest I got.
hello! you got it wrong.
are you trying to have a single counter displaying the total score? gold give 5 score, broze give 1 score, etc…
if so… the concept is very simple:
1: if player is in collision with coin, add the corresponding value to the variable containing the total score.
2: display total score
(note that there should be zero math involved when you write the string that will be displayed as the text. the addition operation is done in the variable (stored as a number). all you want to do, is display it.) ![]()
here is the simplest form you can make it.
this is a slightly more optimised version for your pc:
i can tell that string operations confuse you. Unless what you want to achieve is different than what i unserstood
string operations serve as a way to add words to a sentence.
the only uses for your situation (it seems). is adding a “score:” before the variable that contains the score.
so.. instead of your score counter looking like this…

it would look like this:
![]()
why do you have three different variables containing the information of the score, when you want to add them together??
if you want to add score together. you only need a SINGLE variable that hold the information of the score. a bronze coin adds one to the score. a silver coin add three to the SAME variable. same goes for the gold.
that is… unless you want to display each coin as their own seperate counters.
you are still attempting to do the addition inside of the string
![]()
string addition when displaying a string to a text object does not serve the purpose of keeping in memory the addition of the two strings. the addition: coins + gold coins (which i don’t even know what it means) is not stored anywhere in memory. it only says: “look, when you display the variable, please put another word side by it”.
in fact, i would advise beginners to not do string operations before watching some kind of tutorial about the difference between numbers and strings.
you see, the action: [ change the text of ] cannot do any additions, multiplications, divisions, modulo, power, or any other number operation between the terms (terms are the ones seperated by a plus or minus). what you don’t realize, in this code:
the variable [gold_coin] (which should be called total_score) is a number. the proper writing would be:
"coins: " + ToString(Gold_Coin)
this is because this whole event (change the text to) can only return a string. if you call a number, the function will have an error. But you CAN put a number, only if you turn it into a string at the end. everything outside the ToString function is operated as a string. meaning pluses don’t behave the same
the reason why neglecting the ToString notation is possible, is only because Gdevelop automatically detects that the variable you are calling is of the wrong type, and must be converted to string (it does that without telling you). I know, thats terrible design and make the learning curve more strange because the program hides stuff from you.
because of this, you think you add numbers, but in reality… you actually add strings
if you truly do want to keep the information of how many coins you cumulated of each types AND have a total totalizing your points. you could have a forth variable on top of having your other three variables (gold_coin, silver_coin). one that is called total_points. or you do the addition inside of the string but encapsulated inside a ToString function manually (otherwise, GDevelop perform a ToString for each variables individually, which prevent any number operations)
here is the second method:
in this case, the number operations are still performed at the writing into the string. But… because all number operations are contained inside a ToString function, Gdevelop doesn’t automatically individually convert them into string. which would prevent number operations. What is inside the ToString function is basically “protected” from the auto ToString, until what is indide has been reduced to a single term. after that, it does the rest of the operations as strings.
this, I think is what you originally wanted
Wow it worked thank you so much! I appreciate the help and the effort. But yeah my main goal was just to display them as a total that added them all together as one total score. ![]()






