-- поиск билжайшей цели в пределах дистанции

function module.findNearestHead(pos,max_dist)
	local children
	local target = nil
	local target_head = nil
	local rayResult = nil
	
	for _, player in pairs(find:GetChildren()) do
		local target_head = player:FindFirstChild("Head")
		if target_head ~= nil then
			if player:FindFirstChild("Humanoid") ~= nil then
				local hum=player:FindFirstChild("Humanoid")
				if player:FindFirstChild("Team") ~= nil and hum.Health>0 then			
					if (target_head.Position - pos.Position).magnitude < max_dist and player.Team.Value~="Ally" then				
						-- поиск ближайшего
						if target == nil or (target_head.Position - pos.Position).magnitude < (target.Position - pos.Position).magnitude then
							target=target_head
							-- rayResult = myRay(target,pos,max_dist)
							rayResult = true -- проверка что тормозят райкасты