Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

[SOLVED] Way to get the children of children?

Explorer looks a bit like this:

- ScreenGui
	- Frame1
		- Frame2
			- Button
			- Button
		- Frame3
			- Button

I can use Frame2:GetChildren() and Frame3:GetChildren() combined to get the buttons. I need to get the buttons using only one function. Is there a way?

[EDIT]

I've found a way, you simply use i, v in pairs twice.

for index, value in pairs(Frame:GetChildren()) do
	for i, v in pairs(value:GetChildren()) do
		-- stuff
	end
end

1 answer

✓ Accepted answer

A better way than what you are already did is to simply make a recurse function.

function recurse(o)
	for i,v in pairs(o:GetChildren()) do
		pcall(function()
			--if statement here
			recurse(v)	
		end)
	end
end

recurse(Frame)

This discussion is preserved as it was. New answers, comments, and votes are closed.