Number Variable as a text object [SOLVED]

Hi! I tried looking for other topics, but they are from several years ago and don’t seem accurate to the current version. I am trying to make a system where when you attack an enemy, they take a random amount of damage (from 12 to 20). However, not matter what I try, I cannot convert the number variable into a string so I can display it on a text object when the enemy gets hit. How can I fix this?

I’ve done a quick search, and all of the topics around this that I can find are accurate.

In general, anytime you want to convert a number to a string, you have to use the “ToString()” expression. I’d recommend using the expression builder, as it will show up as Number > Text, and then you can put in whatever number/variable/expression you want.

This is also how the Coins score is displayed in the platformer example, if you want to see it in use.

I probably should have checked the templates games first lol… but thanks! It works perfectly now.

1 Like