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

Script that utilizes math.random not working?

Asked by 8 years ago

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
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. Pyrondon 2089 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

Nevermind, I believe I have fixed it.

0
Remember to mark your question as answered LittleBigDeveloper 245 — 8y
Ad

Answer this question