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

How to choose between random strings?

Asked by 3 years ago

Just like you can pick random number with math.random are there any way to pick between random strings for example printing out random strings between : "Hi welcome" or "Hi how are you"

1 answer

Log in to vote
1
Answered by 3 years ago

You could do that with this simple example:

local stringTable = {

    "sneaky beaky",
    "Hello world!",
    "helo my friendo",
    "yeah",
    "yes",
    "no"

}
local randomString = math.random(1,#stringTable)

for i,v in pairs(stringTable) do

    if i == randomString then

        print(v)

    end

end

You can add as many strings as you want!

0
Thank you again my friend! mastercheeseit 77 — 3y
0
Thank you again my friend! mastercheeseit 77 — 3y
Ad

Answer this question