How do I loop my light animation is javascript?

Hi guys, I have a trigger that when I collide with it my light is triggered and flashes. I tried using wrap mode loop but it still just plays once, my code is below, does anyone know why this doesn’t work?

var myLight : Light;

function Start() {
	myLight = GameObject.Find ("Alarm Light").GetComponent(Light);
	myLight.enabled = false;
}


function OnTriggerEnter (other : Collider)
{
    if (!AlarmSetOff)
    {
		myLight.enabled = !myLight.enabled;
		myLight.animation["LightFlash"].wrapMode = WrapMode.Loop;
    }
}

You should make a boolean and a Update function, it will loop automatically.

var alarmIsRunning : boolean = false;
var myLight : Light;
 
function Start() {
    myLight = GameObject.Find ("Alarm Light").GetComponent(Light);
    myLight.enabled = false;
}

function Update(){
  if (alarmIsRunning){
     myLight.animation.Play("LightFlash");
  }
}
 
function OnTriggerEnter (other : Collider)
{
    if (!AlarmSetOff)
    {
       myLight.enabled = !myLight.enabled;
       alarmIsRunning = !alarmIsRunning;
    }
}