light a reference to a component attached to a game object, presumably the same one this script is attached to? If not, you'll need a reference to it, and you'll need to assign it at some point, like so:
public class Flashlight : MonoBehaviour
public bool flashOn;
public Light light;
// After saving this script, the light field should appear
// in the inspector alongside your flashOn boolean field.
// You may assign it manually there, or through code at runtime.
// I prefer the latter, and it is done like so:
public void Awake()
light = GetComponent<Light>();
flashOn = !flashon;
light.intensity = 0;
light.intensity = 1;
You may also find it useful to review the Unity API documentation for
I adjusted your script a little here, changing
GetKeyDown. This way it will only change the state of the flashlight once when your key of choice is pressed, rather than toggling it every frame while the key is pressed, which I assume is not the intended functionality as it would be very difficult for a player to press a button for only a single frame.
Good luck with your game!