I made a health bar gui, and I want it to show the amount of health you have, but when I get damaged it shows a long decimal. How do I use math.floor to round the value?
✓ ANSWER ACCEPTED
How does math.floor work?
1 answer
✓ Accepted answer
math.floor uses one argument, which is the number you want to ROUND DOWN, for example
HealthNumberTextlabel.Text = math.floor(Health)
There's also math.ceil, if you want to round a number upwards.
4 comments
0
Would it work if I did script.Parent.PlayerGui.Bars.HP.Fraction.Text = math.floor(hum.Health.."/"..hum.MaxHealth)
0
It doesn't accept strings or multiple values. Something like this: script.Parent.PlayerGui.Bars.HP.Fraction.Text = math.floor(hum.Health).."/"..hum.MaxHealth
0
Ah, ok that works.
0
PLEASE EDIT SAYING IT ROUNDS DOWN
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Math.floor rounds the value down. If you want a function that rounds the value based on whether it's above or below 0.5, here: http://pastebin.com/cDZnn295