I'm trying to remove 3 Instances from this table, the Script and two parts named Base and Sort individually, however in the first loop, the Instance Sort is ignored, for whatever reason. But in the second loop, the Instance Sort is included. I'm really confused. I thought that maybe the game didn't fully load yet, and that Sort wasn't loaded, so i added this repeat loop to make sure that there are only 13 instances in the table (the number of children), but it still didn't work. Every child's name is printed except for Sort.
Server script:
local parts
repeat
parts = script.Parent:GetChildren()
until #parts == 13
for i, child in pairs(parts) do
print(child.Name)
if child == script or child.Name == 'Sort' or child.Name == 'Base' then
table.remove(parts, i)
end
end
for i, child in pairs(parts) do
child.SurfaceGui.TextLabel.Text = child.Name
end
I also get an error that states that Sort doesn't have a child named SurfaceGui, because, well, it doesn't, but Sort shouldn't be in the table at all.

1 comment
I edited my answer, I hope this explains it better.