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: [Help] Auto adding data to tables

Previous Thread :: Next Thread 
ghostbusters43 is not online. ghostbusters43
Joined: 15 Mar 2011
Total Posts: 112
16 Nov 2016 03:17 PM
I have a dance floor and I am trying to insert all surface GUI's into their own separate rows (I got 14 rows). My main problem is line 3: 'table.insert(["row"..i],0,v)' I cannot do '["row"..i]' cause the script won't let me and I can't do '"row"..i' cause it doesn't accept strings (the quotes around it makes the script think it's a string) How do I do this?

for i=1,14 do
for i,v in pairs(script.Parent.Plates["Row"..i]:GetChildren()) do
table.insert(["row"..i],0,v)
end
end
Report Abuse
HalfPinky456 is not online. HalfPinky456
Joined: 10 Apr 2011
Total Posts: 6236
16 Nov 2016 03:19 PM
shouldn't the row be uppercase?
Report Abuse
ghostbusters43 is not online. ghostbusters43
Joined: 15 Mar 2011
Total Posts: 112
16 Nov 2016 03:21 PM
I didn't but I can change that later..
Report Abuse
ghostbusters43 is not online. ghostbusters43
Joined: 15 Mar 2011
Total Posts: 112
17 Nov 2016 07:25 AM
I still don't have a answer btw
Report Abuse
Emilarity is not online. Emilarity
Joined: 15 Dec 2008
Total Posts: 1625
17 Nov 2016 08:04 AM
it's impractical to access variables with strings like that
I recommend storing all your row tables in one giant table
then just iterate through that giant table when inserting
but if you MUST do it your way, you can use getfenv
that will give you a table of all global variables
(make sure your row tables are global and not local)

local fenv = getfenv() -- store this previously

then later...

table.insert(fenv["row"..tostring(i)],0,v) -- in the loop


Report Abuse
Emilarity is not online. Emilarity
Joined: 15 Dec 2008
Total Posts: 1625
17 Nov 2016 08:05 AM
also you have a logic error, consider using "for k,v in pairs" in your second for loop because the "i" overwrites the one from the first loop that you are actually trying to use


Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
17 Nov 2016 08:19 AM
local tab = {}

for i,v in next, plates:GetChildren() do
tab[v.Name] = true
end

or you can do

table.insert(tab,v.Name)


Report Abuse
ghostbusters43 is not online. ghostbusters43
Joined: 15 Mar 2011
Total Posts: 112
17 Nov 2016 08:42 AM
@Emilarity thanks so much! I would put it into one big row but I need to change colors in rows unless there is a simpler way
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