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

What does this mean?

It comes out in my output:

bad argument #2 to 'random' (interval is empty)

2 answers

✓ Accepted answer

It means that you made an error in argument 2(the second number)

Breaking down the error:

  • bad argument #2: The second value you gave to a function was "bad" (didn't make sense)
  • to 'random': The function that was given a bad value was math.random
  • (interval is empty): This is a hint explaining why the value was bad.

The 2-parameter use of math.random is math.random(low, high).

If high is less than low, then the interval [low, high] (in math notation) is empty -- there is no number at least low and less than high.


A frequent cause of this error is code that looks like this:

list = {}

print( math.random(1, #list) )

This is a problem, since #list is 0 and 0 is less than 1.

Usually, it's not so obvious -- more likely, you're using :GetPlayers() or :GetChildren() when there are none.

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