NPC damaging itself

So I made an ability for an NPC, but every time it uses it, it gets damaged. How would I make it where it wouldn’t damage itself?

if hit.Parent:FindFirstChild("Humanoid") and not hit.Parent:FindFirstChild("AlreadyHit") and not hit:IsDescendantOf(NPC.Humanoid) then
	local enemyHumanoid = hit.Parent:FindFirstChild("Humanoid")
	local alreadyHit = Instance.new("BoolValue")
	alreadyHit.Parent = hit.Parent
	alreadyHit.Name = "AlreadyHit"
	enemyHumanoid:TakeDamage(35)
1 Like

It’s most likely attacking every Humanoid, so you could make it so it ignores it self like so.

if Humanoid and v ~= script.Parent then --This checks if it's attacking a humanoid, BUT not itself. 
--Continue with your code

Edit: You probably will have to use for i for this to work.

2 Likes

In the if statement add this line:
and hit.Parent ~= NPC
Just replace NPC with however you defined your NPC, or if the script is under the NPC you can just do script.Parent

2 Likes

All I did was just add an int value to the NPC called “NPC” then wrote this line.

if hit.Parent:FindFirstChild("NPC") then return end
3 Likes

That works too but it’s not the best method. Good job anyways.