-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --


local damagetime
local damagedb = false

for _, zambieparts in pairs(zombie:GetChildren())do
	if zambieparts:IsA'Part' and human.Health > 0 then
		zambieparts.Touched:connect(function(p)
			if p.Parent.Name == chaseName and p.Parent.Name ~= zombie.Name and not damagedb then -- damage
				damagedb = true
				damagetime = time()
				local enemy = p.Parent
				local enemyhuman = getHumanoid(enemy)
				vars.Attacking.Value = true
				enemyhuman.WalkSpeed = 0
				local animation = script.Parent.Zombie:LoadAnimation(script.Parent.Attack)
				animation:Play()
				script.Parent.HumanoidRootPart.Theme:Stop()
				head.Jumpscare:Play()
				wait(0.83)
				head.Hit2:Play()
				enemyhuman:TakeDamage(ZombieDamage)
				wait(1)
				script.Parent.HumanoidRootPart.Theme:Play()
				vars.Attacking.Value = false
				while wait() do
					if damagetime ~= nil and time() >= (damagetime + DamageWait) then
						damagedb = false
						damagetime = nil
					end
				end
			end
		end)
	end
end
