FunguyI
|
  |
| Joined: 11 Sep 2009 |
| Total Posts: 1412 |
|
|
| 05 Aug 2012 05:34 PM |
Basically, I have a table, they are bricks, part of a gate that I will sue i na function lcick script that will make these disappear when a button is clicked but it does not work. The output says Workspace.GateLasers.Script4:table index is nil.
Here is my script that does not work:
Lasers = {script.Parent.Lasers.Laser1; script.Parent.Lasers.Laser2; script.Parent.Lasers.Laser3; script.Parent.Lasers.Laser4; script.Parent.Lasers.Laser5; script.Parent.Lasers.Laser6; script.Parent.Lasers.Laser7; script.Parent.Lasers.Laser8; script.Parent.Lasers.Laser9; script.Parent.Lasers.Laser10}
for i=0, 10, .1 do Lasers[Transparency] = i * .1 wait(.1) end
|
|
|
| Report Abuse |
|
|
Dr01d3k4
|
  |
| Joined: 11 Oct 2007 |
| Total Posts: 17916 |
|
|
| 05 Aug 2012 05:38 PM |
It's beacuse you're trying to access the 0th index of the table - Lua starts at 1.
for trans = 0, 1, 0.1 do for l = 1, 10 do script.Parent.Lasers["Laser"..l].Transparency = trans; end wait(0.1); end |
|
|
| Report Abuse |
|
|
FunguyI
|
  |
| Joined: 11 Sep 2009 |
| Total Posts: 1412 |
|
| |
|
Dr01d3k4
|
  |
| Joined: 11 Oct 2007 |
| Total Posts: 17916 |
|
|
| 05 Aug 2012 06:03 PM |
Actually, the error I said is both right and wrong. It's wrong because you're trying to access the "Transparency" index, and Transparency is a nil value which means it's trying to find nil in the table. It's also right because if you changed Transparency to i, it would try to find the 0th index.
Tl;dr: just try my code. |
|
|
| Report Abuse |
|
|
josh50000
|
  |
| Joined: 29 Nov 2009 |
| Total Posts: 697 |
|
|
| 05 Aug 2012 06:06 PM |
| i would have done that an easier way :/ |
|
|
| Report Abuse |
|
|
Dr01d3k4
|
  |
| Joined: 11 Oct 2007 |
| Total Posts: 17916 |
|
|
| 05 Aug 2012 06:08 PM |
| My way is easier than his - less lines and easier to expand with Laser11, Laser12 etc, just as long as you don't skip a number, but even then you could just hardcode special cases. |
|
|
| Report Abuse |
|
|