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 » Scripters
Home Search
 

Re: Tables

Previous Thread :: Next Thread 
Vendicular is not online. Vendicular
Joined: 12 Apr 2013
Total Posts: 218
13 Sep 2015 02:51 PM
I can manually make a table like

table = {
["Vendicular"] = 1
}

but how do i use a script to insert something like that?

I tried:

mom = script.Parent
mom.Touched:connect(function(part)
table.insert(pplat, part.Parent.Name, 1)
end)

and it returns:
Workspace.TouchPad.Touched:5: bad argument #2 to 'insert' (number expected, got string)
Report Abuse
Foreboding is not online. Foreboding
Joined: 22 Aug 2010
Total Posts: 19154
13 Sep 2015 02:51 PM
local = table()


#code print ("Shots fired, ready for the war!") -- Currently working on Gui's
Report Abuse
RecurringNightmare is not online. RecurringNightmare
Joined: 05 Jul 2012
Total Posts: 15336
13 Sep 2015 02:52 PM
what is pplat
Report Abuse
Vendicular is not online. Vendicular
Joined: 12 Apr 2013
Total Posts: 218
13 Sep 2015 02:52 PM
^ wat
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
13 Sep 2015 02:52 PM
"table.insert(pplat, part.Parent.Name, 1)"
pplat[part.Parent.Name] = 1
Report Abuse
SenseiWarrior is not online. SenseiWarrior
Joined: 09 Apr 2011
Total Posts: 12140
13 Sep 2015 02:52 PM
local tab = {
["Potatoes"] = 1;
}

tab["Shrooms"] = 2;

print(tab.Shrooms)
Report Abuse
Vendicular is not online. Vendicular
Joined: 12 Apr 2013
Total Posts: 218
13 Sep 2015 02:52 PM
pplat is name of table i forgot to include it
Report Abuse
RecurringNightmare is not online. RecurringNightmare
Joined: 05 Jul 2012
Total Posts: 15336
13 Sep 2015 02:53 PM
the arguments go in the order of"

table

index #

value to insert
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
13 Sep 2015 02:56 PM
Expanding on my answer (Since nobody but Sensei seem to know what they are doing)
The reason is, you could also do this:
table[1] = blah, table[2] = blah, et cetera
But what if you wanted to insert a value in between a couple of values?
That's what table.insert is for. table.insert is for working with ordered lists, which use numerical indices.
table.insert(Table, 5, blah) -- Inserts blah between 4 and 5, and moves everything after 4 over one
Table[5] = blah -- Overwrites Table[5], causing the previous value to be lost.
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
13 Sep 2015 02:58 PM
And since dictionaries (Tables with non-integer keys) are not ordered, table.insert doesn't work with them.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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