Jump to content




[Question] Getting a random string from a table?


  • You cannot reply to this topic
2 replies to this topic

#1 Mackan90096

  • Signature Abuser
  • 518 posts
  • LocationIn my basement.

Posted 13 May 2013 - 01:12 AM

I'm currently testing things out and I'm wondering if you can get a random string from a table?

Like from a table:
local table = {"string1", "string2", "string3"}

And only one of those strings..

Can you do that? And if so, how?

#2 Shnupbups

  • Members
  • 596 posts
  • LocationThat place over there. Y'know. The one where I am.

Posted 13 May 2013 - 01:14 AM

local table = {"string1","string2","string3")
local randomString = table[math.random(#table)]


#3 Mackan90096

  • Signature Abuser
  • 518 posts
  • LocationIn my basement.

Posted 13 May 2013 - 01:15 AM

Thanks :)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users