Drooling Zombies Killing Each other

So i was making a game and for some reason Drooling Zombies kill each other! i tried changing the AI module script so that when something is not called “Zombie (1)” (zombie name) then attack it but it still doesn’t work! (the scripts are from a free model “Drooling Zombie” from ROBLOX)

Could you show where you added the “check” that makes the zombie not target each other.

Oh and, I suggest using CollectionService instead of just relying on the AIs username.

this is the whole function that i edited

local function handleHit(other)
		if canHit then
			if other and other.Parent and other.Parent.Name ~= "Zombie (1)" and other.Parent:FindFirstChild("Humanoid") then
				local enemy = other.Parent						
				if enemy.Humanoid.WalkSpeed > 0 then
					enemy.Humanoid.Health = enemy.Humanoid.Health - configs["Damage"]
					canHit = false
				end
			end
		else
			local now = os.time()
			if now - lastHit > configs["DamageCooldown"] then
				lastHit = now
				canHit = true
			end
		end
	end

Are you sure the zombie AI actually uses this function? And not like, some other attack function?

it is used on arms

local leftHitConnect, rightHitConnect
	leftHitConnect = model:FindFirstChild("Left Arm").Touched:connect(handleHit)
	rightHitConnect = model:FindFirstChild("Right Arm").Touched:connect(handleHit)

Use Ctrl+Shift+F, check if any other script inside the AI touches anything related to Health.

Try this code out:

local whitelistedNames = {"zombie1", "zombie2", "boss"}

local function HandleHit(hit: BasePart)
	if canHit then
		local char: Model = hit.Parent
		local hum: Humanoid = char:FindFirstChildWhichIsA("Humanoid")
		
		if hum and not table.find(whitelistedNames, char.Name) then
			hum.Health -= configs["Damage"]
			canHit = false
		end
	else
		local now = os.time()
		if now - lastHit > configs["DamageCooldown"] then
			lastHit = now
			canHit = true
		end
	end
end

leg.Touched:Connect(HandleHit)
1 Like

omg it works!!! thank you so much!!