Distance thing with gameobject ?

hello guys, i want my AI's not to be too closer , so i made a code like this in the AI:

function Update()
{

var friend = GameObject.FindWithTag("UnGoro");

WHAT SHOULD I PUT HERE TO MAKE MY AI TO PUT A DISTANCE AT LEAST 10 BETWEEN HIS FRIEND?
}

please help :)

Distance is used to get the distance between two objects - not change them. Your error is coming from the fact that you need to do

friend.transform.position

Your script (this should be attached to your AI) should do something like this:

function Update()
{
if (Vector3.Distance(transform.position,friend.transform.position) > 10)
{
//some code to move the ai towards your player
}
else
{
//stop the ai
}
}

actually the thing i want to make is different , i edited it , i don't want to make if statement or make the AI to move toward my player.

I'm something like observer in the scene, i have 10 characters in group A 10 characters in group B fighting with each other with swords.

I want group A characters to have at least 10 meters between each other.

I belive that "friend" already is a default var by Unity, try changing you var name.

Also, you'll need to do like:

var friend = GameObject.FindWithTag("UnGoro");

function Update()
{

if (Vector3.Distance(transform.position,friend.position) > 10)
{
 //Move the object 10, maybe using instanitate or something, the ofcourse can't SEE it walk
} 

Maybe you can attach waypoints to the players, that are as far as tou like away from the player, and the other players follow those waypoints.

Put This Script In Your Friend:
Put the tag Player in your player and don’t put your player in the “var Player : Transform”.

var Player : Transform;
var MoveSpeed = 10.0;
private var StopSpeed = 0.0;
var RangeToStop = 10.0;
var damp = 5;

function Update () {
Player = GameObject.FindWithTag("Player").transform;

if(Vector3.Distance(Player.position,transform.position) > RangeToStop){
   var rotate = Quaternion.LookRotation(Player.position - transform.position);
   transform.rotation = Quaternion.Slerp(transform.rotation, rotate,damp * Time.deltaTime);
   transform.Translate(0,0, MoveSpeed * Time.deltaTime);
  }else{
  if(Vector3.Distance(Player.position,transform.position) < RangeToStop){
   var rotate2 = Quaternion.LookRotation(Player.position - transform.position);
   transform.rotation = Quaternion.Slerp(transform.rotation, rotate2,damp * Time.deltaTime);
   transform.Translate(0,0, StopSpeed * Time.deltaTime);
  }
  }
}