I have an AI script that I tweaked for a strategy-ish game and I want it to shoot and both players and other AIs that are not owned by the creator of the AI (bit complicated init)

This script finds other AIs and players near this AI's torso, however it doesn't seem to work.

anyway, this is the script (it is called later on in the script):

function findNearestTorso(pos)
	local list = game.Workspace:children()
	local torso = nil
	local dist = 1000
	local temp = nil
	local human = nil
	local zombie = nil
	local temp2 = nil
	for x = 1, #list do
		temp2 = list[x]
		if (temp2.className == "Model") and (temp2 ~= script.Parent) then
			temp = temp2:findFirstChild("Torso")
			human = temp2:findFirstChild("Humanoid")
			if (human == nil) then
				zombie = temp2:findFirstChild("Zombie")
				print(temp2)
				if (zombie ~= nil) then
				if zombie.Parent.Owner.Value ~= script.Parent.Owner.Value then
				local zomt = zombie.Parent:FindFirstChild("Torso")
				torso = zomt
				dist = (zomt.Position - pos).magnitude
				end
				end
			end
			if (temp ~= nil) and (human ~= nil) and (human.Health > 0) and not (human.Parent.Name == script.Parent.Owner.Value) then
				if (temp.Position - pos).magnitude < dist then
					torso = temp
					dist = (temp.Position - pos).magnitude
				end
			end
		end
	end
	return torso
end

Other info:

The "Zombies" under the name "Soldier" are under another model called Model in Workspace.