|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
| |
|