How to get children of a child?

Hi, i wanted to ask how could i get the children of children, So like if a part has 3 circles in it and thoso circles have lights how could i get thoso lights?

so like:

local children = script.Parent:GetChildren():GetChildren

Would that work?

for i,v in pairs(script.Parent:GetChildren()) do
for i2,v2 in pairs(v:GetChildren()) do
print(i2,v2)
end
end

hi this is my script:

local Folder = script.Parent.Folder

for i, v in pairs(Folder:GetChildren()) do
		
		repeat
			wait(0.05)
			v.PointLight.Brightness += -0.1
		until
		v.PointLight.Brightness == 0

end

i wanted to ask how could i make the for i loop Do all the parts lights at the same time? Not one by one?

you can use task.spawn()

you could use tweenservice instead of repeat loop

example useage of task.spawn:

local Folder = script.Parent.Folder

for i, v in pairs(Folder:GetChildren()) do
		task.spawn(function()
		repeat
			wait(0.05)
			v.PointLight.Brightness += -0.1
		until
		v.PointLight.Brightness == 0
       end)
end

Hi thanks you have been alot of help!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.