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

How do I use math.random On A Table?

Asked by 10 years ago

Right, let's say I was making a loading screen, and I had a few subtitles to put under my game title. I want to select a random one to use. My script is:

_G.Print(script.Parent.Loading, "LOADING CERTIA", .07)

Subs = {"Reading thermonuclear reactor...", "Building weapons...", "Debugging...", "Manufacturing vehicles...", "Testing targeting matrix..."} 
wait(1)
local NOT = 0
repeat
    wait(3)
    script.Parent.Loading.Loading2.Text = nil
    _G.Print(script.Parent.Loading.Loading2, Subs[math.random(1,5)], 0.07)
    NOT = NOT + 1
until NOT == 5

Now, I want to pick a random string out of the array Subs to use for printing at line 10. It all goes well until I try to use math.random(1,5). Even my global print function is working. What's the deal there?

Answer this question