Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How does math.floor work?

Asked by
DVDKO 20
8 years ago

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?

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 AmiracIe 175 — 8y

1 answer

Log in to vote
1
Answered by
drew1017 330 Moderation Voter
8 years ago

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.

0
Would it work if I did script.Parent.PlayerGui.Bars.HP.Fraction.Text = math.floor(hum.Health.."/"..hum.MaxHealth) DVDKO 20 — 8y
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 drew1017 330 — 8y
0
Ah, ok that works. DVDKO 20 — 8y
0
PLEASE EDIT SAYING IT ROUNDS DOWN DigitalVeer 1473 — 8y
Ad

Answer this question