generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: math.random for string?

Previous Thread :: Next Thread 
thane1326 is not online. thane1326
Joined: 08 Apr 2009
Total Posts: 867
24 Dec 2012 08:32 PM
Hey I'm trying to make a string randomizer, but it chooses from a list that I pick, not just any. Can someone help?
Report Abuse
1Topcop is not online. 1Topcop
Joined: 09 Jun 2009
Total Posts: 6635
24 Dec 2012 08:32 PM
Strings = {"String","Stuff","Here"}
print(Strings[math.random(1,#Strings)])

?
Report Abuse
thane1326 is not online. thane1326
Joined: 08 Apr 2009
Total Posts: 867
24 Dec 2012 08:35 PM
Thanks, is their any way I can do it so it chooses two that go together? Becouse I'm making a game that You have to guess the phrase. like, Phrase = ("Hi", Banana's), ("No", "Pajamas")
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
24 Dec 2012 08:36 PM
Random pairs? Make another table and do the same thing.
Report Abuse
IamAwesome777 is not online. IamAwesome777
Joined: 18 Jul 2011
Total Posts: 2640
24 Dec 2012 08:36 PM
    local words = {"Hello","Bye","apple","roblox"} -- Add your words here.
    print(words[math.random(1,#words)])
Report Abuse
IamAwesome777 is not online. IamAwesome777
Joined: 18 Jul 2011
Total Posts: 2640
24 Dec 2012 08:37 PM
Whoops late post.
Report Abuse
1Topcop is not online. 1Topcop
Joined: 09 Jun 2009
Total Posts: 6635
24 Dec 2012 08:37 PM
Like....

function trandom(t)return t[math.random(1,#t)]end
Beg = {"Hello","Hi"}
Fin = {"!","...","."}
print(trandom(Beg)..trandom(Fin))

?
Report Abuse
thane1326 is not online. thane1326
Joined: 08 Apr 2009
Total Posts: 867
25 Dec 2012 01:03 AM
OMG I don't understand that, but You just solved the problem to an awesome game, when it's done, I'll ask You how I can repay You.
Report Abuse
thane1326 is not online. thane1326
Joined: 08 Apr 2009
Total Posts: 867
25 Dec 2012 01:24 AM
Wait, what if I wanted it so it didn't matter how much capitals they had, so it could be all caps, or all lowercase, becouse that's a problem too.
Report Abuse
Jonah13249 is not online. Jonah13249
Joined: 09 Oct 2009
Total Posts: 2105
25 Dec 2012 02:57 AM
:lower()
:upper()

??

~ṡсɾïρτïṉģ hεlρεɾṡ ۩ lυαlεαɾṉεɾṡ ④ øƒвќṃṿј~ ღ ▂▃▅▆█ρεώḋïερïε☄сυτïερïε█▆▅▃▂ღ 【▬】
Report Abuse
jelly134 is not online. jelly134
Joined: 25 Aug 2008
Total Posts: 1137
25 Dec 2012 02:59 AM
if msg:lower() == phrase:lower() or msg:upper() == phrase:upper() then
Report Abuse
peaspod is not online. peaspod
Joined: 29 Sep 2010
Total Posts: 2809
25 Dec 2012 08:12 AM
words = {"lol", "banana","troll"}

for i, v in pairs (words) do
print(words[math.random(1, #words)]
end
Report Abuse
peaspod is not online. peaspod
Joined: 29 Sep 2010
Total Posts: 2809
25 Dec 2012 08:13 AM
I think I got that wrong:

fixed:

words = {"lol", "banana","troll"}

for i, v in pairs (words) do
print(words[math.random(1, #v)]
end
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
25 Dec 2012 10:58 AM
    words = {"lol", "banana","troll"}
    for i, v in pairs (words) do
      print(words[math.random(#words)]
    end

> Penguin Power
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image