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 » Scripters
Home Search
 

Re: Help with this table

Previous Thread :: Next Thread 
FatherRage is not online. FatherRage
Joined: 25 Dec 2011
Total Posts: 520
15 May 2013 01:30 AM
table = {"Hello", "Hi", "Bye","Lol"}

local randomvalue = table[math.random(1, #table)]

Instance.new("Message").Parent = game.Workspace
game.Workspace.Message.Text = randomvalue


It selects a random value and says it.

but I want to do, say if it selected Lol it does a certain command. How do I do that?
Report Abuse
woot3 is not online. woot3
Joined: 10 Nov 2008
Total Posts: 3599
15 May 2013 01:39 AM
tabl = {"Hello","Hi","Bye","Lol"}

local ran = tabl[math.random(1,#tabl)]
Instance.new("Message",game.Workspace).Text = ran
if ran == "Lol" then
-- Do stuff
end
Report Abuse
SCARFACIAL is not online. SCARFACIAL
Joined: 28 Jan 2010
Total Posts: 7970
15 May 2013 01:40 AM
Here, this should make you feel better:

do
   local OldTableLibrary = table
   table = {}
   table.flip = function(tab)
      local newtab = {}
      for i=#tab, 1, -1 do
         table.insert(newtab, tab[i])
      end
   return newtab
   end
   setmetatable(table, {__index = function(self, index) return rawget(self, index) or    OldTableLibrary[index] end})
end

local t = table.flip({"Hello", "Hi", "Bye","Lol"})

local randomvalue = table[math.random(1)]

Instance.new("Message").Parent = game.Workspace
game.Workspace.Message.Text = randomvalue
Report Abuse
FatherRage is not online. FatherRage
Joined: 25 Dec 2011
Total Posts: 520
15 May 2013 01:42 AM
Thank you guys.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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