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

{SOLVED!} How to use GetChildren to count children with a specific name?

If I were to use :GetChildren() to count the children with a specific name in the players backpack, how will I do so?

The tool I'm trying to count is in the players backpack (cloned from serverstorage)

1 answer

function countChildrenByName(name,location)
	local count = 0
	for i,v in pairs(location:GetChildren()) do
		if v.Name == name then
			count = count + 1
		end
	end
	return count
end

location is where you want to get the amount with the name

Wikipages

For Loops

GetChildren

Return

Don't forget to accept my answer if it worked! :)

Edit: ops did not see it's solved

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