Is there a simple way to detect if a kill script touches the parent of the part?

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)

if not Hit:IsDescendantOf(Part.Parent) and Hit and Hit.Parent then

Sorry, which line do I put this at?

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)
local Part = script.Parent
local Damage = script.Parent:WaitForChild("Damage").Value

function Dmg(Hit)
+	if not Hit:IsDescendantOf(Part.Parent) and Hit and Hit.Parent then
		local Humanoid = Hit.Parent:WaitForChild("Humanoid")
		if Humanoid then
			Humanoid:TakeDamage(Damage)
				
			end
		end
	end

Part.Touched:connect(Dmg)
1 Like