How would I play a sound in a certain range of an object?

I am not sure what I have done wrong in this script I have created, I used my knowledge of java to put this together, but not sure why this is not working. taking a guess, maybe I have done it in a wrong layout?

var theplayer : GameObject;
var speed : float;
var range : int;

public var close : AudioClip;
public var aware : AudioClip;
public var retreat : AudioClip;

function Update (){

range=Vector3.Distance(theplay.transform.position,transform.position);
{
if (range<40){
      transform.LookAt(theplay.transform.position);
      AudioSource.PlayClipAtPoint(aware, transform.position);
}
}
{
range=Vector3.Distance(theplay.transform.position,transform.position);
if (range<20){
      AudioSource.PlayClipAtPoint(close, transform.position);
}
}
{
range=Vector3.Distance(theplay.transform.position,transform.position);
if (range<12){
      transform.Translate(-Vector3.forward*speed);
      AudioSource.PlayClipAtPoint(retreat, transform.position);
}
}
}

You used “theplay”, but the variable’s name is theplayer.
Why do you use PlayClipAtPoint instead of assign an AudioSource in the inspector and then change the clip?