|
| 10 Apr 2014 09:36 PM |
Just began using tables, so I'm fairly new to them. Still can't get this to work though:
colors = {"Bright red", "Bright yellow", "Deep orange"} while wait() do colorchosen = math.random(1,#colors) script.Parent.BrickColor = colorchosen end
Output: 19:33:25.537 - Workspace.Center.Script:4: bad argument #3 to 'BrickColor' (BrickColor expected, got number) |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 10 Apr 2014 09:37 PM |
colorchosen in your case is a number between 1-3, not the actual value in the table.
colorchosen = colors[math.random(1, #colors)] --index the value and since BrickColor property takes a BrickColor value, not string, do: script.Parent.BrickColor = BrickColor.new(colorchosen) |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2014 09:39 PM |
| Thanks a lot mate! Cheers! |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2014 09:40 PM |
colors = {"Bright red", "Bright yellow", "Deep orange"} while wait() do colorchosen = math.random(1,#colors) script.Parent.BrickColor = BrickColor.new(colors[colorchosen]) end
I think you can do that as also. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 10 Apr 2014 09:42 PM |
Yup, or event:
colors = {BrickColor.new("Bright red"), BrickColor.new("Bright yellow"), BrickColor.new("Deep orange")}
while wait() do script.Parent.BrickColor = colors[math.random(#colors)] end |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|