Currently there is no function that easily allows you to get the model containing a part, even if the part is inside x number of sub models. For example, clicking the hat part on a character to get the character model
It would be useful if this function was built into the engine, so I can do workspace:FindFirstChildWithDescendant(RaycastResult.Instance)
function Module.FindFirstChildWithDescendant(Parent, Descendant, CutoffAt)
local CheckParent = Descendant.Parent
repeat
if (CheckParent == Parent) then
-- Search success
return Descendant
end
Descendant = CheckParent
CheckParent = CheckParent.Parent
until not CheckParent or CheckParent == CutoffAt
-- Search failed
end