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

How do I find how many Descendants of a certain type there are in one hierarchy?

Below is the code I'm running to find the Children I need, but another aspect I need with it is finding out how many Children there are. Thank you!

local sP = script.Parent

local descendants = sP:GetDescendants()
for index, descendant in pairs(descendants) do
	if descendant:IsA("NumberValue") then
		print(descendant)
	end
end

1 answer

✓ Accepted answer
local sP = script.Parent

local descendants = sP:GetDescendants()
local amt = 0

for index, descendant in pairs(descendants) do
    if descendant:IsA("NumberValue") then
        print(descendant)
        amt = amt + 1
    end
end

print(amt)

1 comment

0

That's really simple, thanks!

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