|
| 23 Jul 2015 01:57 AM |
| Like if I had math.random(0.1,0.5) would it work? Or would I have to do something more advanced..? |
|
|
| Report Abuse |
|
|
|
| 23 Jul 2015 01:59 AM |
http://www.roblox.com/Forum/ShowPost.aspx?PostID=159594866
|
|
|
| Report Abuse |
|
|
gooey333
|
  |
| Joined: 24 Mar 2013 |
| Total Posts: 1208 |
|
|
| 23 Jul 2015 02:16 AM |
| Yah, read post above... No other answer |
|
|
| Report Abuse |
|
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
| |
|
|
| 23 Jul 2015 02:30 AM |
math.random () returns a random number between 0 and 1 exclusive, therefore math.random ()*(upperBound-lowerBound) + lowerBound If the lower bound is always 0 math.random ()*upperBound
This gives very long decimals and is the "right" way of doing it, as in the most similar to other languages, most flexible kind of way. To get integers out, math.floor the output for [lower, upper) and math.ceil for (lower, upper] |
|
|
| Report Abuse |
|
|
|
| 23 Jul 2015 02:33 AM |
"math.floor the output for [lower, upper) and math.ceil for (lower, upper]"
Or average with math.floor(num + 0.5) |
|
|
| Report Abuse |
|
|