Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How does math.floor work?

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?

1 comment

0

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

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.