# Parts within a nested for loop over nested arrays unable to be manipulated after first pass

So I have a feeling this is an engine bug, but I am not allowed to post bug reports and this could just be me not fully understanding some underlying aspect of tables. With that out of the way here is the problem:

I was working on boss attack for my current project which involved having a grid of parts. I decided to create a nested array to do this([x][y]).

When running the code I found an odd bug where when looping over the array with a nested for loop, any part not contained on [n] was unable to be manipulated by code within the second for loop.

I wrote up a basic script in a new baseplate place to test this as well:

``````local t = table.create(10, table.create(10, 0))

for a, b in ipairs(t) do
for c, d in ipairs(b) do
local p = Instance.new("Part")
p.Anchored = true
p.Position = Vector3.new(a*10, 10, c*10)
p.Parent = workspace
t[a][c] = p
end
end

for a, b in ipairs(t) do
for c, d in ipairs(b) do
d.Position = Vector3.new(d.Position.X, 1, d.Position.Z)
print("test")
end
end
``````

Running this results in this arrangement of parts in the workspace

and with “test (x100)” being correctly displayed in the output.

Modifying Position in this is just for a clear visual, this seems to encompass anything and everything that involves modifying the properties of the Part, including functions that would change a Part’s properties, such as SetAttribute and Destroy.

here is the problem

``````local t = table.create(10, table.create(10, 0))
``````

all elements of table `t` contain exactly the same sub-table.
you should do something like this:

``````local t = table.create(10, 0)
for i = 1, #t do
t[i] =  table.create(10, 0)
end
``````

that will solve the problem.