How to use :GetPartsInPart, but only for base parts with specific names

I am trying to check upon render stepped if a HumanoidRootPart is in range of a part’s bounding box. this way, the enemy that the part is in will only look at the HumanoidRootPart when it is in range. But when I use :GetPartsInPart I can’t seem to find a way to check if a part in the table is a HumanoidRootPart. I know the solution is probably quite simple, could someone inform me?

humanoid root part has a Name property of “HumanoidRootPart”
aka its name is HumanoidRootPart

which means that you can loop through the touching parts and check if any of them is a humanoid root part by doing, if touchingPart.Name == "HumanoidRootPart then...
example



local part :BasePart 


local touchingParts = workspace:GetPartsInPart(part)

for _, part in touchingParts do
	if part.Name == "HumanoidRootPart" then
		--code
	end
end
1 Like

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