Can't get script from raycast

Solved
The script keeps spitting an error out
the error says: “Object reference not set to an instance of an object”

private int layermask = 1 << 8;
    private RaycastHit hit;

    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(1))
        {
            if (Physics.Raycast(transform.position, transform.forward*3f, layermask))
            {
                Debug.Log("gaming");
               -- errors here \/
                if (hit.collider.gameObject.GetComponentInParent<DoorOpenScript>()) {
                    DoorOpenScript theOther = hit.collider.gameObject.GetComponentInParent<DoorOpenScript>();
                    theOther.DoorUsed();

                }
            }

        }

    }

You have defined a variable called hit, but never actually assign anything to it - so of course it is going to be null. Perhaps you should be using one of the versions of the Raycast method where you can get info of what you actually hit and then use that variable.

oomph! that was fairly obvious thanks