Please Help With This Error Code! CS0118

Please Help With This Error Code I have Not Been Able To Make it Work!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class offonlight : MonoBehaviour {
public light light;
	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
		   if (Input.GetButton("Fire1"))  {
		GameObject.GetComponent<Light>().intensity = 0;
      }
	 }
	}

I’m a beginner to Unity but from what I understand, it looks like you want to change THIS object’s light intensity. The code on line 11 will not work for this. Instead, I would use something like this:

GetComponent().intensity

But assuming you are correct in line 11, I noticed that your light variable is named light. Could this be messing up your script? Try changing the name of your light variable.

You were declaring light but then calling upon GameObject. This should fix your problem:

public class Offonlight : MonoBehaviour
{
    public GameObject Light;

    void Update()
    {
        if (Input.GetButton("Fire1"))
        {
            Light.GetComponent<Light>().intensity = 0;
        }
    }
}