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 » Scripting Helpers
Home Search
 

Table not working.

Previous Thread :: Next Thread 
FunguyI is not online. 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 is not online. 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 is not online. FunguyI
Joined: 11 Sep 2009
Total Posts: 1412
05 Aug 2012 06:02 PM
uhh...wut? 0.0
Report Abuse
Dr01d3k4 is not online. 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 is not online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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