if shield got hit show

hey guys i know i heve alreddy asked somthing like this but maybe you will know what i want with this its a simple idea i have a force shield arround me

now you see it all the time i want it to only show everytime it gots hit

i have the mashine gun and the standard rockerd louncher from the sirst person tut so both rigidbody weapons and raycast weapons

could you please make a script for me i dont know the codes

Here is my way how i would make it: The shield must have a collider with trigger activated

var Shot : boolean = false;
var Timer : float;

function Update (){
//Normaly it's not showen
renderer.enabled = false;

 if (Shot){
    //The time wich defines how long the sphere is showen
   Timer += Time.deltaTime;
   //If You make 0.1 its shorter showen if you make 2 it's longer showen
     if (Timer < 1){
     renderer.enabled = true;
     }
     //If the time runs out it's dosen't showen
     else {
     renderer.enabled = false;
     Shot = false;
     }
  }
  // Reset the Timer
  else {
  Timer = 0;
  }
}
// This change Shot if something touches the Forcefield
function OnTriggerEnter (){
    Shot = true;
}

Good luck I hope it works Cery

Ps: There is a better way than mine but i don't know how. Sorry for bad english