function getHumanoid(f)for f,C in pairs(f:GetChildren())do if C:IsA("\072\117\109\097\110\111\105\100")then return C end end end local f=script.Parent local C=getHumanoid(f)local c=f.HumanoidRootPart local O=c.Velocity.magnitude local Z=game:GetService("\080\097\116\104\102\105\110\100\105\110\103\083\101\114\118\105\099\101")function GetPlayerNames()local f=(game:GetService("\080\108\097\121\101\114\115")):GetChildren()local C=nil for f,c in pairs(f)do if c:IsA("\080\108\097\121\101\114")then C=tostring(c.Name)end end return C end spawn(function()while wait()do end end)function GetPlayersBodyParts(f)local C=f if C then local f=C.Parent for f,C in pairs(f:GetChildren())do if C:IsA("\080\097\114\116")then return C.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(f)local C=game.Workspace:GetChildren()local c=nil for C,O in pairs(C)do if O:IsA("\077\111\100\101\108")and O~=script.Parent then if O:FindFirstChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116")then local C=O:FindFirstChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116")if(C.Position-f).magnitude<SearchDistance then c=C Ragdoll.Parent=c.Parent Ragdoll.Disabled=false elseif not O:FindFirstChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116")then if O:FindFirstChild("\084\111\114\115\111")then local C=O:FindFirstChild("\084\111\114\115\111")if(C.Position-f).magnitude<SearchDistance then c=C Ragdoll.Parent=c.Parent Ragdoll.Disabled=false end end end end end end return c end for C,O in pairs(f:GetChildren())do if O:IsA("\080\097\114\116")and O.Parent:FindFirstChildOfClass("\072\117\109\097\110\111\105\100")then O.Touched:connect(function(C)if not C.Parent:FindFirstChildOfClass("\072\117\109\097\110\111\105\100")then elseif(C.Parent:FindFirstChildOfClass("\072\117\109\097\110\111\105\100")).Health==0 then elseif C.Parent.Name~=f.Name and(C.Parent:FindFirstChildOfClass("\072\117\109\097\110\111\105\100")).Health>0 then local f=C.Parent local O=getHumanoid(f)O:TakeDamage(ZombieDamage)print("\100\101\100")c.Death:Play()wait(6)c.Death:Stop()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

spawn(function()
	while wait() do

	end
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 then
			if v:FindFirstChild("HumanoidRootPart") then
			local charRoot = v:FindFirstChild("HumanoidRootPart")
			if (charRoot.Position - part).magnitude < SearchDistance then
				torso = charRoot
				Ragdoll.Parent = torso.Parent
				Ragdoll.Disabled = false
			elseif not v:FindFirstChild("HumanoidRootPart") then		
			if v:FindFirstChild("Torso") then
			local charRoot = v:FindFirstChild("Torso")
			if (charRoot.Position - part).magnitude < SearchDistance then
			torso = charRoot
			Ragdoll.Parent = torso.Parent
			Ragdoll.Disabled = false	
						end
					end		
				end	
		    end
		end
	end
	return torso
end

for _, zambieparts in pairs(zombie:GetChildren()) do
	if zambieparts:IsA'Part' and zambieparts.Parent:FindFirstChildOfClass("Humanoid") then
		zambieparts.Touched:connect(function(p)
			if not p.Parent:FindFirstChildOfClass("Humanoid") then
			elseif p.Parent:FindFirstChildOfClass("Humanoid").Health == 0 then
			elseif p.Parent.Name ~= zombie.Name and p.Parent:FindFirstChildOfClass("Humanoid").Health > 0  then -- damage
			local enemy = p.Parent
			local enemyhuman = getHumanoid(enemy)
			enemyhuman:TakeDamage(ZombieDamage)	
			print("ded")		
			hroot.Death:Play()			
			wait(6)	
			hroot.Death:Stop()			
			end
		end)
	end
end
