hello guys I have a simple AI .when I test it sounds not play .how can I solve this problem.sounds not play.

var distance;
var target : Transform;
var lookAtDistance = 15.0;
var attackRange = 10.0;
var moveSpeed = 5.0;
var damping = 6.0;
var lookatsound : AudioClip;
var attacksound : AudioClip;

//to call each audio clip


    private var isItAttacking = false;
 
    function Update () 
    {
    distance = Vector3.Distance(target.position, transform.position);
 
    if(distance < lookAtDistance)
    {
    isItAttacking = false;
    renderer.material.color = Color.yellow;
    lookAt ();
    }   
    if(distance > lookAtDistance)
    {
    renderer.material.color = Color.green; 
    }
    if(distance < attackRange)
    {
    attack ();
    }
    if(isItAttacking)
    {
    renderer.material.color = Color.red;
    }
}
 
 
function lookAt ()
{
   


       audio.clip = lookatsound;
       audio.loop = true;
       audio.Play();    // play the lookat sound.
       
       
       
    
 

var rotation = Quaternion.LookRotation(target.position - transform.position);
transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * damping);



}
 
function attack ()
{
    isItAttacking = true;
 if (attacksound)
    {
       if (audio.clip != attacksound)
       {
         audio.Stop();    // stop the lookat audio so we can switch out the audio clip.
         audio.clip = attacksound;
         audio.loop = true;   // change the clip, then play
         audio.Play();
       }
    }
 


   
    

    renderer.material.color = Color.red;
 
    transform.Translate(Vector3.forward * moveSpeed *Time.deltaTime);
  
}

in the editor have you assigned a sound to the lookatsound and attacksound? You can do this by dragging and dropping.

Also it appears that you will call audio.Play() every frame if within the lookdistance. I recommend adding:

if (!audio.isPlaying) {
audio.Play();}