local x local C local n=nil function GetTorso(x)local C=game.Workspace:GetDescendants()local k=nil local M=nil local T=nil local i=nil local t=SearchDistance script.Parent.WantToAttack.Changed:Connect(function()if script.Parent.WantToAttack.Value==true then t=SearchDistance else if script.Parent.WantToScare.Value==true then t=SearchDistance/1.5 else t=0 end end end)for e=1,#C,1 do T=C[e]if T:IsA("\077\111\100\101\108")and(not T:FindFirstChild("\069\110\101\109\121")and T:FindFirstChild("\083\101\101\110"))then i=getHumanoid(T)k=T:FindFirstChild("\072\117\109\097\110\111\105\100\082\111\111\116\080\097\114\116")if k~=nil and(i~=nil and(i.Health>0 and(not i:FindFirstChild("\069\110\101\109\121")and not T:FindFirstChild("\072\101\108\112\101\114"))))then if(k.Position-x).magnitude<t then n=T.Name M=k t=(k.Position-x).magnitude end end end end return M end function GetPlayersBodyParts(x)local C=x if C then local x=C.Parent for x,C in pairs(x: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


local path
local waypoint

local chaseName = nil

function GetTorso(part)
	local chars = game.Workspace:GetDescendants()
	local chaseRoot = nil
	local chaseTorso = nil
	local chasePlr = nil
	local chaseHuman = nil
	local mag = SearchDistance
	script.Parent.WantToAttack.Changed:Connect(function()
		if script.Parent.WantToAttack.Value == true then
			mag = SearchDistance
		else
			if script.Parent.WantToScare.Value == true then
				mag = SearchDistance/1.5
			else
				mag = 0
			end
		end
	end)
	for i = 1, #chars do
		chasePlr = chars[i]
		if chasePlr:IsA'Model' and not chasePlr:FindFirstChild("Enemy") and chasePlr:FindFirstChild("Seen") then
			chaseHuman = getHumanoid(chasePlr)
			chaseRoot = chasePlr:FindFirstChild'HumanoidRootPart'
			if chaseRoot ~= nil and chaseHuman ~= nil and chaseHuman.Health > 0 and not chaseHuman:FindFirstChild("Enemy") and not chasePlr:FindFirstChild("Helper") then
				if (chaseRoot.Position - part).magnitude < mag then
					chaseName = chasePlr.Name
					chaseTorso = chaseRoot
					mag = (chaseRoot.Position - part).magnitude
				end
			end
		end
	end
	return chaseTorso
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
