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

What does number m and number n in math.random mean?

Asked by 6 years ago
Edited 6 years ago

math.random(number m, number n)

0
*M* = Minimum *N* = Number (Maximum) print(math.random(5, 10)) -- Gives any random number between 5 and 10 bjr29 40 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

As mentioned in the above answer, the two arguments mean these two things:

  • M is the minimum number.
  • N is the maximum number.

However, number can be a bit misleading. This is because math.random() only takes integers, not floating-point numbers (decimals). That means that this would work…

1local num = math.random(1, 10)

…but this would throw an error:

1local num = math.random(0.01, 0.1)
Ad

Answer this question