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

Script that utilizes math.random not working?

This script is supposed to extract a random number between 1 and the size of an array.

The script works fine the first time, but when conducting a second time, it fails to work.

Output gave me this: "bad argument #1 to 'random' (interval is empty)"

Can someone please help me?

Here's the script:

local a = math.random(1, #Strings)
local b = math.random(1, #Strings2)
String.Value = Strings[a]
String2.Value = Strings2[b]
table.remove(Strings, a)
a = math.random(1, #Strings)
b = math.random(1, #Strings2)

1 comment

1

That error means that the 2nd argument is not greater than the first. Check if #Strings and #String2 are more than 1 to fix it.

1 answer

Nevermind, I believe I have fixed it.

1 comment

0

Remember to mark your question as answered

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