Enemy has to throw stones to the Player

I am making a game for mobile devices where the Enemy has to throw to the Player stones and when in range should face the Player. The stones should be thrown at a random time or every 10 seconds, for instance, when both characters are, lets say, to a distance of 10 units. I wrote a Javascript that makes most of the job: when in range the Enemy start facing the Player, but the Enemy start to launch a continue sequence of stones! I suppose this is an effect of the Function Update and Instantiate (if I change Function Update for Start Function I get a single burst of stones) I need that each stone could be launched automatically every 5 or 10 seconds (var : float; or at random)

Anyone can help me on this?

//EnemyController.js
var target : Transform;
var range = float;
var Enemy : GameObject;
static var mode = "idle";
var stone : Rigidbody;
var stoneSpeed = float;
var throwSound : AudioClip;
var stone : Rigidbody;
var throwForce : float;
static var canThrow : boolean = false;
var numberStone : float;
var StoneLauncher : GameObject;

function Awake()
{
    if(!target)
    {
        target = GameObject.FindWithTag("Player").transform;
    }
}

function Update() 
{   
    if(target && CanAttackTarget())
    {
        var targetRotation = Quaternion.LookRotation(target.position - transform.position, Vector3.up);
        transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.deltaTime * 1.2);        
        audio.PlayOneShot(throwSound);

        var relativePos = target.position - transform.position;
        var rotation = Quaternion.LookRotation(relativePos);
        transform.rotation = rotation;

        stone.rigidbody.AddForce(transform.forward * 5000);
        var stone = Instantiate(stone, GameObject.Find("StoneLauncher").transform.position,
        rotation);   
        Physics.IgnoreCollision(transform.root.collider, stone.collider, true); 
    }
}
function CanAttackTarget()
{
    //Check if the target is close enough
    if(Vector3.Distance(transform.position, target.position) > range)
    {
        return false;
    }   
        var hit : RaycastHit;

    //Check if there's collision between Enemy & target
    if(Physics.Linecast(transform.position, target.position, hit))
    {
        if(hit.collider.gameObject.tag != "Player")
        {
            return false;
        }
        else
        {   
            return true;
        }
    }
    return true;
}

in the function CanAttackTarget(). You could add a simple:

var attackTimer:float;
var attackDelay:int = 10;

if(Time.time<attackTimer){ return false; }
else{ attackTimer = Time.time + attackDelay; }

That'd basically create a 10sec timer. When ready, you'll simply change the 'nextReady' value to 10 secs later. I did not test your whole example but its an operation I do quite often. I'm confident that works :)

EDIT: Sorry, my example isn't so clear but I'd declare the variable OUTSIDE the function. The if/else does goes inside, though.