function getHumanoid(N)for N,x in pairs(N:GetChildren())do if x:IsA("\072\117\109\097\110\111\105\100")then return x end end end local N=script.Parent local x=getHumanoid(N)local o=N.HumanoidRootPart local w=o.Velocity.magnitude local V=game:GetService("\080\097\116\104\102\105\110\100\105\110\103\083\101\114\118\105\099\101")function GetPlayerNames()local N=(game:GetService("\080\108\097\121\101\114\115")):GetChildren()local x=nil for N,o in pairs(N)do if o:IsA("\080\108\097\121\101\114")then x=tostring(o.Name)end end return x end function GetPlayersbodyParts(N)local x=N if x then local N=x.Parent for N,x in pairs(N:GetChildren())do if x:IsA("\080\097\114\116")then return x.Name end end else return"\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116"end end function Getbody(N)local x=game.Workspace:GetChildren()local o=nil for x,w in pairs(x)do if w:IsA("\077\111\100\101\108")and(w~=script.Parent and w.Name==GetPlayerNames())then local x=w:FindFirstChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116")if(x.Position-N).magnitude<SearchDistance then o=x end end end return o end for x,o in pairs(N:GetChildren())do if o:IsA("\080\097\114\116")then o.Touched:connect(function(x)if x.Parent.Name==GetPlayerNames()and x.Parent.Name~=N.Name then local N=x.Parent local o=getHumanoid(N)o:TakeDamage(ZombieDamage)end end)end end



function getHumanoid(model)
	for _, v in pairs(model:GetChildren()) do
		if v:IsA'Humanoid' then
			return v
		end
	end
end


local zombie = script.Parent
local human = getHumanoid(zombie)
local hroot = zombie.HumanoidRootPart
local zspeed = hroot.Velocity.magnitude


local pfs = game:GetService("PathfindingService")

function GetPlayerNames()
	local players = game:GetService('Players'):GetChildren()
	local name = nil
	for _, v in pairs(players) do
		if v:IsA'Player' then
			name = tostring(v.Name)
		end
	end
	return name
end


function GetPlayersbodyParts(t)
	local body = t
	if body then
		local figure = body.Parent
		for _, v in pairs(figure:GetChildren()) do
			if v:IsA'Part' then
				return v.Name
			end
		end
	else
		return "HumanoidRootPart"
	end
end

function Getbody(part)
	local chars = game.Workspace:GetChildren()
	local body = nil
	for _, v in pairs(chars) do
		if v:IsA'Model' and v ~= script.Parent and v.Name == GetPlayerNames() then
			local charRoot = v:FindFirstChild'HumanoidRootPart'
			if (charRoot.Position - part).magnitude < SearchDistance then
				body = charRoot
			end
		end
	end
	return body
end

for _, zambieparts in pairs(zombie:GetChildren()) do
	if zambieparts:IsA'Part' then
		zambieparts.Touched:connect(function(p)
			if p.Parent.Name == GetPlayerNames() and p.Parent.Name ~= zombie.Name then -- damage
				local enemy = p.Parent
				local enemyhuman = getHumanoid(enemy)
				enemyhuman:TakeDamage(ZombieDamage)
			end
		end)
	end
end
