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

How To Use Percentage In ROBLOX Lua?

Asked by 9 years ago

'Cause % Stands for Modulus, what stands for percentage, or does it have to be created myself?

0
I've answered your comment. Shawnyg 4330 — 9y
0
hehe woodengop 1134 — 9y

2 answers

Log in to vote
4
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
9 years ago

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!

0
Well, this is an example, but if I did: .5 * game.Players.NumPlayers, is it then 50 % of players? SwaggyDuckie 70 — 9y
0
It'll return the number of half the players, yes. @SwaggyDuckie Say if it's 10 players, it'll return 5. Shawnyg 4330 — 9y
0
But...but I explained my answer yumtaste 476 — 9y
Ad
Log in to vote
2
Answered by
yumtaste 476 Moderation Voter
9 years ago

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.

0
Heh, beat you by 5 seconds. Shawnyg 4330 — 9y
0
o o f sngnn 274 — 4y

Answer this question