Basically I need to check for a part that is a descendant of a model with a humanoid parented to said model for a damage function that my gun system uses because the bullets are being caught on hats and armor preventing the damage from working.
if part:FindFirstAncestorOfClass("Model") then -- getting the first ancestor that is a Model
local char = part:FindFirstAncestorOfClass("Model")
if char:FindFirstChildOfClass("Humanoid") then -- checking if a Humanoid exists in said ancestor
-- code here
end
end
Alright, I fixed it myself. For anyone coming to this for an answer, here you go:
local hitPart = workspace.examplepart
local fullpath = hitPart:GetFullName()
local names = string.split(fullpath,".")
local humanoid = game.Workspace[names[2]]:FindFirstChildOfClass("Humanoid")
5/17/24 edit:
you can also just disable query on armor parts if you’re using raycasts (i believe? havent tested) or exclude anything with an armor tag (update exclude table accordingly to armor removal or addition)