for example i have global variable Health=100
i want when i press a button to add to Health +5%
can someone help me ?
5% = 5/100, or 1/20.
So on button pressed, set health to health+(health/20).
Develop games in your browser. Powerful, performant & highly capable.
it works but has 420.25 and on 3th click text disappears
i did the box bigger but now on the 4th click disappears
Eventually with percentages you will get a non even number, with a lot of decimals that won't fit into your text box.
You can make your text box bigger, or try using floor(number) or round(number) instead to get rid of the decimal value.