How to repeat with Boolean?

Hi there! I need to know how i can repeat this Script with a Boolean.
So there’s a Speeder and when it comes near the Location point, it’ll be activated ONCE, and then it ends. So how can i reacivate this Script when i come near the same Point a Second Time?

I receive this: Expressions in statements must only be executed for their side-effects.
But i don’t know why.

var speeder : GameObject;
var shadow : GameObject;
var TestLoc : GameObject;
private var aggroRadius :float = 150;
var isActive : boolean = true;

function Start ()
{
 speeder = GameObject.Find("DummySpeeder");
}

function Update ()
{
 if (isActive)
 {

var distance = Vector3.Distance(speeder.transform.position, transform.position);
if distance < aggroRadius)
{

Instantiate (TestLoc,transform.position, transform.rotation);
Instantiate (shadow,transform.position, transform.rotation);

Destroy(gameObject);
}
}

else
{
distance > aggroRadius;
}
}

Firstly, if your looking for distance of the speeder, why not use a Sphere Collider?

Then you could just use
OnTriggerEnter
and
OnTriggerExit

however, if you must do it this way from some reason

public void Update()
{
     if(isActive)
     {
         float distance = Vector3.Distance(speeder.transform.position, transform.position); 
         if distance < aggroRadius) 
         {
              Instantiate (TestLoc,transform.position, transform.rotation); 
              Instantiate (shadow,transform.position, transform.rotation);
              isActive = false;
              StartCoroutine(ExitWhatShouldHaveBeenATriggerCollider());
         }
     }
}

IEnumerator ExitWhatShouldHaveBeenATriggerCollider()
{
    yield return null;
    while(Vector3.Distance(speeder.transform.position, transform.position) < aggroRadius)
        yield return null;
    isActive = true;
}

Thanks a lot! i’ve now this:

var speeder : GameObject;
var shadow : GameObject;
var TestLoc : GameObject;
private var aggroRadius :float = 150;
var isActive : boolean = true;


function Update()
{
     if(isActive)
     {
         var distance = Vector3.Distance(speeder.transform.position, transform.position);
         if (distance < aggroRadius) 
         {
              Instantiate (TestLoc,transform.position, transform.rotation); 
              Instantiate (shadow,transform.position, transform.rotation);
              isActive = false;
              StartCoroutine(ExitTestLoc());
         }
     }
}

IEnumerator ExitTestLoc()

{
    yield return 0;
    while(Vector3.Distance(speeder.transform.position, transform.position) > aggroRadius);
        yield return 0;
        isActive = true;
}

Now i receive an Error: UCE0001: ‘;’ expected. Insert a semicolon at the end. But i can’t see any missing Semicolon there… could that be a Bug?

What i need to do is only a repeat when i reach the point one more Time. So they spawn on a track. 6 Locators are on it, and it must be, that they spawn again and again, whenever i pass the Point.
(i’ve used Javascript. Don’t know another.)

Okay, so it doesn’t repeat the Script and only one Locator is working, but ignoring the Aggro Radius. When i press Play it spawns, whereever i am.

function Update()
{
     if(isActive)
     {
         var distance = Vector3.Distance(speeder.transform.position, transform.position);
         if (distance < aggroRadius) 
         {
              Instantiate (TestLoc,transform.position, transform.rotation); 
              Instantiate (shadow,transform.position, transform.rotation);
                                    
              isActive = false;
              StartCoroutine(ExitTestLoc());
         }
         
     }
}

function ExitTestLoc()

{
    yield;
        while(Vector3.Distance(speeder.transform.position, transform.position) > aggroRadius);
        yield;
    isActive = true;
}

So it does not Run anyway. Nothing spawns, nowhere. So isn’t there a Possibility to do this Loop with a simple Boolean true/false thing?

Something like this? So this does’nt repeat it if i leave the Place… but maybe you can help me?

function Start ()
{
 speeder = GameObject.Find("DummySpeeder");
}

function Update ()
{
 if(isActive)
 {
 var distance = Vector3.Distance(speeder.transform.position, transform.position);
 if (distance < aggroRadius)
 {
 Instantiate (TestLoc,transform.position, transform.rotation);
 Instantiate (shadow,transform.position, transform.rotation); 
 
 Destroy(gameObject); 
 }
 }
 if (distance > aggroRadius)
 {
 isActive = true;
 }
 
}