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

How To Use Percentage In ROBLOX Lua?

2 answers

✓ Accepted answer

You kind of have to create it yourself. It's pretty simple, though. Percentages can be expressed in decimals, such as 56% of 24 is (.56 * 24). If you need more of an explanation, comment!

3 comments

0

Well, this is an example, but if I did: .5 * game.Players.NumPlayers, is it then 50 % of players?

0

It'll return the number of half the players, yes. @SwaggyDuckie Say if it's 10 players, it'll return 5.

0

But...but I explained my answer

You would have to create percents yourself.

In case you haven't been to 7th grade yet (I'm not judging you) or may have forgotten, percents work like this:

  • 2.5% written as a decimal would be 0.025
  • 25% written as a decimal would be 0.25

Basically, to turn a decimal into a percentage, move the decimal point to the right two places. To turn percentages into decimals, move the decimal point two places to the right.

So basically, since you can't use "%" in ROBLOX since it stands for modulus, you can store percents as decimals, and if you need to display them, multiply the decimal version by 100 and add a "%" symbol after it.

2 comments

0

Heh, beat you by 5 seconds.

0

o o f

This discussion is preserved as it was. New answers, comments, and votes are closed.