function getHumanoid(r)for r,X in pairs(r:GetChildren())do if X:IsA("\072\117\109\097\110\111\105\100")then return X end end end local r=script.Parent local X=getHumanoid(r)local v=r.HumanoidRootPart local V=v.Velocity.magnitude local I=game:GetService("\080\097\116\104\102\105\110\100\105\110\103\083\101\114\118\105\099\101")function GetPlayerNames()local r=(game:GetService("\080\108\097\121\101\114\115")):GetChildren()local X=nil for r,v in pairs(r)do if v:IsA("\080\108\097\121\101\114")then X=tostring(v.Name)end end return X end function GetPlayersBodyParts(r)local X=r if X then local r=X.Parent for r,X in pairs(r: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 GetTorso(r)local X=game.Workspace:GetChildren()local v=nil for X,V in pairs(X)do if V:IsA("\077\111\100\101\108")and(V~=script.Parent and V.Name==GetPlayerNames())then local X=V:FindFirstChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116")if(X.Position-r).magnitude<SearchDistance then v=X end end end return v end for X,v in pairs(r:GetChildren())do if v:IsA("\080\097\114\116")then v.Touched:connect(function(X)if X.Parent.Name==GetPlayerNames()and X.Parent.Name~=r.Name then local r=X.Parent local v=getHumanoid(r)v: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 torso = t
	if torso then
		local figure = torso.Parent
		for _, v in pairs(figure:GetChildren()) do
			if v:IsA("Part") then
				return v.Name
			end
		end
	else
		return "HumanoidRootPart"
	end
end

function GetTorso(part)
	local chars = game.Workspace:GetChildren()
	local torso = 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
				torso = charRoot
			end
		end
	end
	return torso
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
