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 5 years ago
Edited 5 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 — 5y

1 answer

Log in to vote
0
Answered by 5 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...

local num = math.random(1, 10)

...but this would throw an error:

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

Answer this question