Greetings, I was wondering if there was a simple way to detect if a kill script comes into contact with the parent of the main kill part, like the title says. I have an NPC with a part with a kill script on it, but the problem is that it’s just killing itself. I’m just using a generic kill/damage script to achieve this, but I’m not sure how to negate the damage from the parent of the part. Here’s “my” code:
local Part = script.Parent
local Damage = script.Parent:WaitForChild("Damage").Value
function Dmg(Hit)
if Hit and Hit.Parent then
local Humanoid = Hit.Parent:WaitForChild("Humanoid")
if Humanoid then
Humanoid:TakeDamage(Damage)
end
end
end
Part.Touched:connect(Dmg)