I want to make an NPC kill anyone who touches him. My approach was to first create a function onTouch that will set health of who touches him to 0 (health = 0) and then to set each part of the same itself to activate this function on touch using the following code:
for i,v in pairs(script.Parent:GetDescendants()) do
if v:IsA("Part") or v:IsA("MeshPart") then
v.Touched:connect(onTouch)
end
end
Well, something seems to be missing! It kills me except for the following case: when I jump on the NPC's hair, it's not killing me.

9 comments
Hair is an accesory, it isn't a basepart, add it to the 'or' list (or v:IsA('Accessory'))--> Hope I spelled that right xD
Yes I agree
but then it says that "Touched is not a valid member of Accessory"
Oh yeah, the accesory isn't collidable, there is a part inside it called handle (that's a basepart)
Oh...???? Maybe you could turn cancolide off for the accessories? Then you would fall straight through to the NPC's head and be killed? I really don't know ether.
I changed my code to if v:IsA("Part") or v:IsA("MeshPart") or v:IsA("BasePart") then but the hair still doesn't kill me.
Use, elseif v:IsA('Accessory') then v:FindFirstChild('Handle').Touched:Connect(onTouch)
Not working. I mean to say that when I jump on the NPC's hair it still doesn't kill me.
Hm, you probably have the accesory still in your first 'if' statement then (if not, can you update the code?)