Shield won't stop creating.

So I’m trying to do a shield and it keeps creating a shield. Any help would be nice. Thanks

private var shieldOn : boolean = false;

if(Input.GetMouseButtonDown(1)) //"shieldKeyInput	
	{	
		if(!shieldOn)
		{
		var clone = Instantiate(shieldMesh, transform.position, transform.rotation);	
		clone.transform.parent = gameObject.transform;
		shieldOn = true;
		}
		shieldOn = false;
	}
}
    var canClone : boolean = true ;  
         function Update()
{        if(whateverYouHaveHere  Input.GetButtonDown("Fire1")  canClone)
{            //all of that other stuff you have in here          
 //otherstuff          
 //otherstuff           
 //when finished doing other stuff->  
         canClone = false ;     
              }   
  }

if This is in the update function then i think that it gets called each time your mousebutton is down aka as long as your mouse button is down that script will get called.
so basically you create sheild in one frame turn it on then without destroyoing that shield you turn it back off so it gets created again and again while your holding down the mouse button.

it is usually best do do those kinds of instantiations in a Button.GetButtonMouseUP if statements.

@gioworks thank you. @Raigex I didn’t think of that I’ll check that out as well

every time you press the mouse button, you are creating a shield, since you are making shieldOn = false. This should be switched to false using a timer.