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

Is There a Way to Pick a Random String? (SOLVED)

Asked by 6 years ago
Edited 6 years ago

I'm trying to make a script that makes a text say something or say something else, One of the two. I tried doing random but it said it needed a number and not a string.

Can someone help me with that? That would be really helpful for me and I would really appreciate it if you do.

Thanks, MajinBluee

0
You can't make it say a random sentence out of nothing, you can however write a series of strings and put them in a folder in robloxstudios, ie serverstorage, and then randomly pick one of the stringvalues inside that folder? You can pick random numbers because there are only 10 digits,however, there are nearly an infinite number of sentences and roblox simply doesn't have a bank to store them all oggy521 72 — 6y
0
That what I wanted to do MajinBluee 80 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Use tables, I'll make a quick example

local Strings = {'Hello', 'World'}

local st = Strings[math.random(1, #Strings)]
print(st)

(This basicly, makes a random number from 1 to the lenght of the table, and then gets the thing out the table with that index)

0
Another method could be using string.gmatch() iRexBot 147 — 6y
0
This didn't work for me. Asher0606 36 — 5y
Ad

Answer this question