I am attempting to create a table from a :GetTouchingParts() after filtering out some parts. While it works for accessories and colliders within the player, it cannot filter the limbs inside the character itself. I want it so that the output table only has the HumanoidRootPart (do not mind the truss parts)
local touchingParts = launchZone:GetTouchingParts()
local refinedTable = {}
warn("--INPUT TABLE--")
print(touchingParts)
for number, item in pairs(touchingParts) do
if not item.Parent:IsA("Accessory") and not item.Parent:IsA("Part") then
table.insert(refinedTable, item)
elseif item.Parent.ClassName == "Model" and item.Parent.PrimaryPart.Name ~= item.Name then
table.insert(refinedTable, item)
end
end
warn("--OUTPUT TABLE--")
print(refinedTable)
This is the output as of now:

The output should only contain HumanoidRootPart (once again, do not mind the truss parts)
For one, you should probably be using GetPartsInPart. If you’re only looking for the HumanoidRootPart, why not just search specifically for it? If you’re looking for touching player characters, just do something like:
local touchingParts = workspace:GetPartsInPart(part)
local characters = {}
for _,part in pairs(touchingParts) do
if part.Parent:FindFirstChild('HumanoidRootPart') then
if not table.find(characters,part.Parent) then
table.insert(characters,part.Parent)
end
end
end
Use this inside your loop:
if item.Name == "HumanoidRootPart" then
table.insert(refinedTable, item)
end
You can change it to suit your needs. This does remove everything except the HRP.
Because there are other humanoid-like models that don’t specifically use humanoidRootPart as their primary part. I was just using it as an example for a player character.
local touchingParts = workspace:GetPartsInPart(part)
local characters = {}
for _,part in pairs(touchingParts) do
if part.Parent:IsA('Model') then
if part.Parent.PrimaryPart then
if not table.find(characters,part.Parent) then
table.insert(characters,part.Parent)
end
end
end
end
You don’t really need to do anything then. If it has a PrimaryPart, then it’s a player character. I mean, you can also check to see if it as a humanoid to be sure.
Ok, I was able to solve it myself by making a second for loop and table. Thank you for helping out though!