|
| 17 Sep 2012 11:20 AM |
Let's take for example
Table = {"Hello there.", "Goodbye for now"}
function a()
script.Parent.Name = math.random(1, #Table)
end
My problem is that rather than getting the text like 'Hello there.', instead I get numbers like 1, 2, etc.
I've been away from scripting a while so I'm pretty rusty, so what should I do? |
|
|
| Report Abuse |
|
|
1pie23
|
  |
| Joined: 11 Jul 2010 |
| Total Posts: 1865 |
|
|
| 17 Sep 2012 11:21 AM |
Table = {"Hello there.", "Goodbye for now"}
function a() ma = math.random(1, #Table)
script.Parent.Name = Table[ma]
end |
|
|
| Report Abuse |
|
|
nate890
|
  |
| Joined: 22 Nov 2008 |
| Total Posts: 21686 |
|
|
| 17 Sep 2012 11:23 AM |
Ok, that's because you're getting a random number from 1 - the amount of items in Table.
Which is a start, but to finish that off we need to index the random number that we got and put it to good use, like such:
script.Parent.Name = Table[math.random(#Table)]
good luck! |
|
|
| Report Abuse |
|
|
|
| 17 Sep 2012 11:23 AM |
I'm not sure if this is completely correct, but I'm hoping if I'm wrong, and you've done this before, that it might at least help you remember.
Table = {"Hello there.", "Goodbye for now"}
function a()
for i,v in pairs{Table} print(v) end end |
|
|
| Report Abuse |
|
|
|
| 17 Sep 2012 11:25 AM |
| Ah yes, that was it, thanks. |
|
|
| Report Abuse |
|
|
| |
|
nate890
|
  |
| Joined: 22 Nov 2008 |
| Total Posts: 21686 |
|
|
| 17 Sep 2012 01:27 PM |
| Your code doesn't do what it appears he is wanting to do. So probably not your code. |
|
|
| Report Abuse |
|
|