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

How Would You Pull a Random Variable from an Array?

Asked by 10 years ago

I have the array "array1 = {1, 2, 3}", and I'd like to pull a random variable from the table. math.random seems to give me the same sequence of numbers, constantly, rather than being random. Any idea how to make it truly random?

1 answer

Log in to vote
2
Answered by
Discern 1007 Moderation Voter
10 years ago
array1[math.random(1, #array1)]
0
Gives me 1 every time. Vescatur 95 — 10y
0
It works. Keep testin' it. Bebee2 195 — 10y
0
Mm. Must've been giving me 1 every time by random chance, tried it again and it works. Vescatur 95 — 10y
Ad

Answer this question