GetChildren() not working

for _, units in pairs(result) do
	print(units)
	--print(units:GetChildren())
	for _, soldier in pairs(units:GetChildren()) do	-- print out indivual humanoids
		print(soldier)
	end
end

https://gyazo.com/43a3cfc5716736d3c2c8754114fa728a

Why wouldn’t units:GetChildren() work? In this case, units is clearly the individual tables inside of the result table.

1 Like

It looks like it is a table within another table, try this

for _, units in pairs(result) do
	print(units)
	for _, unit in pairs(units) do
		for _, soldier in pairs(unit:GetChildren()) do
			print(soldier)
		end
	end
end
1 Like

That wasn’t quite what I was looking for as it printed out the dummy’s individual parts.
I had solved it by going through each key in the table instead.

for _, units in pairs(result) do
	print(units)
	for i=1,#units do
	    print(units[i])  -- prints out the individual dummys
	end
end

1 Like

Why wouldn’t units:GetChildren() work? In this case, units is clearly the individual tables inside of the result table.

You use :GetChildren() on Instances, it will return a table containing the children of said Instance, you don’t use them on tables

for _, units in pairs(result) do
	print(units)
	for _, soldier in pairs(units) do	-- print out indivual humanoids
		print(soldier)
	end
end
1 Like