GetDescendants() only gets few instances out of hundreds

I’ve made a script for a tool which detects kill bricks in a folder and adds a “Highlight” in order to see them easier. There are several folders with kill bricks, and for that I’m using GetDescendants(). The problem is, it only seems to detect about 10 - 15 parts out of the hundreds in all folders.

Here’s the function where I need help on.

The script is a LocalScript as well if that helps.

task.spawn(function()
	for index, kills:BoolValue in workspace.Towers:GetDescendants() do
		if kills:IsA("BoolValue") then
			if kills.Name == "kills" then
				print("KILLBRICK DETCTED")
				local part = kills.Parent

				local high:Highlight = Instance.new("Highlight")
				high.Parent = part
				high.Name = "KillbrickDetector"
				high.Adornee = part
				high.FillTransparency = 1
				high.OutlineColor = Color3.fromRGB(251, 255, 41)
										
				game:GetService("Debris"):AddItem(high, 15)
			end
		end
	end
end)

The Highlight object has a limit on the number that can be rendered. I heard around the devforum that the cap is at around the 30s Highlights.

Try using SelectionBox to see if they all show as selected, if so, then Highlight object is the issue.


However, if you referring to “KILLBRICK DETECTED” showing up 15 times in the output, then is something totally different to what I said and is related to your if statements.

Seems about right. Switched to SelectionBox and now they all render properly. Thank you so much.

1 Like

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