Make the flashlight follow the mouse.

Here is a flashlight script :

var flashlightOn : boolean = false;
 
function Update () {
    //Checks if the boolean is true or false.
    if(flashlightOn == true){
        light.intensity = 1;//If the boolean is true, then it sets the intensity to what ever you want.
    } else {
        if(flashlightOn == false){
            light.intensity = 0;//If the boolean is false, then it sets the intensity to zero.
        }
    }
   
    //Checks if the F key is down and whether the boolean is on or off.
    if(Input.GetKeyDown(KeyCode.F) && flashlightOn == false){
        flashlightOn = true; //If the f key is down and the boolean is false, it sets the boolean to true.
    } else {
        if(Input.GetKeyDown(KeyCode.F) && flashlightOn == true) {
        flashlightOn = false;//If the f key is down and the boolean is true, it sets the boolean to false.
        }
    }
   
}

How can I make it follow my mouse ?

First, attach this script to a spotlight. Then make this spotlight a child of your main camera. Simply adjust the spotlight so that it looks as if it is being emitted by an unseen flash light.

If you have a 3D model of a flashlight, attach the spotlight (with the script attached) to this flashlight game object, then attach the flashlight game object to the main camera.

If you move the model/ spotlight around, you can position it so that it looks like it is being emitted from a first person view of a(n) (un)seen flashlight.