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

Math.random error (interval is empty)?

Error: 'Bad argument#2 to 'math.random' (interval is empty)

local murderers = math.random(2, #game.Players:GetPlayers())

The script doesn't work. The error is above

1 answer

✓ Accepted answer

bad argument #2 to 'math.random' (interval is empty): This error occurs when the first argument, or the first number inputted, is more than the 2nd argument.

The first argument of math.random will be the minimum number, while the second argument of math.random will be the maximum number.

local list = game.Players:GetPlayers()
local rand1 = math.random(1, #list)
local murderer1 = list[rand1]
table.remove(list, rand1)

local rand2 = math.random(1, #list)
local murderer2 = list[rand2]

1 comment

0

Thank you!

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