Whenever i need to get a Humanoid
from a Touched
event, i need to always do something like this before i can do the function i wanted to do:
script.Parent.Touched:Connect(function(h)
if h.Parent:IsA("Model") then
if h.Parent:FindFirstChildWhichIsA("Humanoid") then
--function
end
elseif h.Parent:IsA("Accessory") then
if h.Parent.Parent:FindFirstChildWhichIsA("Humanoid") then
--function
end
end
end)
Is there a way of shortening this for saving time?
Before replying, i have tried:
-:FindFirstAncestorWhichIsA("Humanoid")
Doesn’t work, as the Accessory
nor the limb part are descendants of the Humanoid.