Targeting other objects of the same type but not self

hi i am making a space game , the problem is when i make the AI try to target another Ai , it targets itself , all the ships are on the same layer and have the same names.

how i can make them target only other ships , also i have the same problem in collision avoiding.

thx for help

You should edit your question and post your script. Anyway, to target another object you must get some reference of it - transform, collider, rigidbody, gameObject etc. Supposing you want to find all AI ships with the same tag and select one of them randomly, you could do something like this:

var target: GameObject;

function FindAI(){
  var ships = GameObject.FindGameObjectsWithTag("AiShip");
  do {
    target = ships[Random.Range(0, ships.length)]; // get a random element
  } while (target == transform.gameObject); // repeat if found itself
}