|
| 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 |
|
|
|
| 16 Nov 2016 03:19 PM |
| shouldn't the row be uppercase? |
|
|
| Report Abuse |
|
|
|
| 16 Nov 2016 03:21 PM |
| I didn't but I can change that later.. |
|
|
| Report Abuse |
|
|
|
| 17 Nov 2016 07:25 AM |
| I still don't have a answer btw |
|
|
| Report Abuse |
|
|
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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|