--Sam

wait (1)
local larm=script.Parent:FindFirstChild("Left Arm")
local rarm=script.Parent:FindFirstChild("Right Arm")
local head=script.Parent:FindFirstChild("Head")

local health=8000 ---zombies health
local speed=14 --zombies walkspeed

local a = 0
function findNearestTorso(pos) --thanks miked for this function <3
	local list = game.Workspace:children()
	local torso = nil
	local dist = script.Range.Value
	local temp = nil
	local human = nil
	local temp2 = nil
	for x = 1, #list do
		temp2 = list[x]
		if (temp2.className == "Model") and (temp2 ~= script.Parent) then
			temp = temp2:findFirstChild("Torso")
			human = temp2:findFirstChild("Humanoid")
			if (temp ~= nil) and (human ~= nil) and (human.Health > 0) then
				if (temp.Position - pos).magnitude < dist then
					torso = temp
					dist = (temp.Position - pos).magnitude
					a = a + 1
					if dist <= 3 and a == 10 then
						script.Parent.Torso["Right Shoulder"].MaxVelocity = 100000  ---attack anim <3
						script.Parent.Torso["Left Shoulder"].MaxVelocity = 100000
						script.Parent.Torso["Right Shoulder"].DesiredAngle = math.pi / 4 * 3
						script.Parent.Torso["Left Shoulder"].DesiredAngle = math.pi / 4 * -3
						script.Parent.Torso["Right Shoulder"].CurrentAngle = math.pi / 4 * 3
						script.Parent.Torso["Left Shoulder"].CurrentAngle = math.pi / 4 * -3
						wait()
						script.Parent.Torso["Right Shoulder"].MaxVelocity = 0.15
						script.Parent.Torso["Left Shoulder"].MaxVelocity = 0.15
					end
					if a == 10 then
					a = 0
					end
				end
			end
		end
	end
	return torso
end

function Hit(hit)
local human = hit.Parent:FindFirstChild("Humanoid")
if human and script.Parent.Zombie.Health>0 then
human.Health= human.Health-script.Damage.Value
end
end
larm.Touched:connect(Hit)
rarm.Touched:connect(Hit)
head.Touched:connect(Hit)

Spawn(function()
while wait(0.5) do
local target = findNearestTorso(script.Parent.Torso.Position)
if target then
script.Parent.Zombie:MoveTo(target.Position, target)
end
end
end)

script.Parent.Zombie.MaxHealth=health
script.Parent.Zombie.Health=script.Parent.Zombie.MaxHealth
script.Parent.Zombie.WalkSpeed=speed


script.Parent.Zombie.Died:connect(function()