lighting script help

i have made this script and it doesnt work. what i was trying was mouse DOWN light ON and mouse UP light off

var islighton = 0;
 
function Update() {
 
if (islighton == 0 && Input.GetKeyDown ("Fire1")) {
 
light.intensity = 1;
}
else if (islighton == 1 && Input.GetKeydown("Fire1")) {
 
light.intensity = 0;
}
}

if someone can show me where i went wrong and amend it that would be great

thanks everyone

Use Input.GetMouseButtonDown(0), not Input.GetKeyDown (and definitely not Input.GetKeydown).

You don’t need the islighton variable at all.

function Update() {
  if (Input.GetMouseButtonDown(0)) {
    light.intensity = 1;
  }
  else if (Input.GetMouseButtonUp(0)) {
    light.intensity = 0;
  }
}