Question, Is There A Way To Round Decimals To The Nearest Whole number?

I’m looking To Make My in-game Position tracker leaderstats To look less technical (e.g. 1.4, 2.9, 3.7, etc. Is technical) So it looks better, I don’t know how to do this.
So Please, Most Answers Help

Math.floor goes to the lowest integer (2.3 → 2, 2.8 → 2), but math.floor(number+0.5) works.

@AridTheDev’s post is more detailed.

1 Like

math.round() math.floor() math.ceil() are 3 things you are looking for.

If you use math.round() on 5.6 the result will be 6.
If you use math.round() on 5.4 the result will be 5.

If you use math.ceil() on 5.1 the result will be 6.
If you use math.ceil() on 5.6 the result will be 6.

If you use math.floor() on 5.9 the result will be 5.
If you use math.floor() on 5.1 the result will be 5.

2 Likes

But @AridTheDev, How would I code in a number?

math.round(5.5) is how you would do it. Just insert the number inside the parenthesis.or brackets ( ).

1 thing, if you use 0.5 on an integer while using math.round() it will send you the next integer.

Obviously not. I was even dumber than you when I started learning. I questioned myself hOw tO dOnwLOaD roBLOx StudDiO 202o??

Thank you @AridTheDev. (Now that I think about It, It Seem so simple, I Feel a little embarrassed, Lol)

1 Like

Don’t forget to mark his reply as a solution.

Thank you, @Downrest I Forgot.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.