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
 

Re: table.insert Use

Previous Thread :: Next Thread 
nickmaster24 is not online. nickmaster24
Joined: 04 Oct 2008
Total Posts: 8906
05 Jun 2012 11:23 PM
00:22:30 - Workspace.TheAI.Think:75: attempt to call field 'insert' (a nil value)

For this line:

table.insert(table, #table+1, val)

Wut?

From Wiki:

"Inserts element value at position pos in table, shifting up other elements to open space, if necessary. The default value for pos is n+1, where n is the length of the table (see §2.5.5), so that a call table.insert(t,x) inserts x at the end of table t."

~Read Between The Squiggles~
Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
05 Jun 2012 11:24 PM
you overwrote table
Report Abuse
nickmaster24 is not online. nickmaster24
Joined: 04 Oct 2008
Total Posts: 8906
05 Jun 2012 11:25 PM
Derp :3

~Read Between The Squiggles~
Report Abuse
miz656 is not online. miz656
Joined: 19 Jul 2010
Total Posts: 15336
05 Jun 2012 11:26 PM
You don't have to have the position you know.

tab = {}
table.insert(tab,"hi")
print(tab[1])
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
05 Jun 2012 11:26 PM
You probably overwrote table, as the other guy said. Don't use table as a variable.

P.S. Your position is redundant. All you need to do is table.insert(table, val) and it will append it to the end automatically.
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