How to turn off flashlight once in water?

How to put a code to automatically turn off the players flashlight once they touch or enter water. Once they get out of the water the flashlight is still off until they press F again.
My flashlight script.

function Update () {

	if (Input.GetKeyDown("f")) {
	
		if (light.enabled == true)
			light.enabled = false;
			else
			
			light.enabled = true;
			}
}

throw a collider on the water. make the collider cover the entrance to the water.

mark the collider as isTrigger

attach this script to the water prefab.

void OnTriggerEnter(collider other)
{
   if(other.tag == "Player")
   { 
     other.GameObject.light.enabled = false;
   }
}

Not sure if the keywords are exact but thats pretty damn close