Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

2 comments

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

0

That what I wanted to do

1 answer

✓ Accepted answer

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)

2 comments

0

Another method could be using string.gmatch()

0

This didn't work for me.

This discussion is preserved as it was. New answers, comments, and votes are closed.