How would I get the children of children

Currently I’m trying to make a PlaybackLoudness thing and I need to get the children of children but I don’t know how, I’ve tried many times but failed. What can I do?

Code:

local parts = game.Workspace.Lights:GetChildren("Light")
local Sound = game.Workspace.CurrentMusic
local parts2 = game.Workspace.Lights2:GetChildren("Part")


Sound:Play()

while Sound.IsPlaying do
	for _, part in next, parts, parts2  do -- Also this keeps causing the error "Invalid key to next?"
		part.Color = Color3.fromRGB(4, 4, Sound.PlaybackLoudness/4);
		parts2.Color = Color3.fromRGB(4, 4, Sound.PlaybackLoudness/4);
	end
	wait();
end

Folder:

image

Umm… try using GetDescendants perhaps?

1 Like

Could you explain more possibly?

the getchildren function isnt for what you are using it for. i, v in pairs doesnt work like you think it does. I would do:

for i, v in pairs Lights:GetChildren() do
	local light = v.SurfaceLight
end
for i,v in pairs (item:GetChildren()) do
 for ii,vv in pairs(v:GetChildren()) do
 end
end