Object reference not set to an instance of an object

I know this question is always asked, but in my case i haven’t found a solution. I have this script:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;

 public class TouchInput : MonoBehaviour {
 
     public LayerMask touchInputMask;
     
     private List<GameObject> touchList = new List<GameObject>();
     private GameObject[] touchesOld;
     public RaycastHit2D hit;
    public GameObject recipient;
     
     // Update is called once per frame
     void Update () {
         
         
 #if UNITY_EDITOR
     
     if(Input.GetMouseButton(0) || Input.GetMouseButtonDown(0)  || Input.GetMouseButtonUp(0)) {
         
         touchesOld = new GameObject[touchList.Count];
             touchList.CopyTo(touchesOld);
             touchList.Clear();
  
         
         
                   //Ray ray = GetComponent<Camera>().ScreenPointToRay(Input.mousePosition);
                 
                   
                    if(Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero)) {
                       
                      recipient = hit.transform.gameObject;
                       touchList.Add(recipient);
                       
                       if(Input.GetMouseButtonDown(0)) {
                           recipient.SendMessage("OnTouchDown", hit.point, SendMessageOptions.DontRequireReceiver);
                           
                       }  if(Input.GetMouseButtonDown(0)) {
                           recipient.SendMessage("OnTouchUp", hit.point, SendMessageOptions.DontRequireReceiver);
                           
                       }  if(Input.GetMouseButtonUp(0)) {
                           recipient.SendMessage("OnTouchStay", hit.point, SendMessageOptions.DontRequireReceiver);
                           
                       }  
                 
     
                     }
                  
                  foreach (GameObject g in touchesOld) {
                      if(!touchList.Contains(g)) {
                          g.SendMessage("OnTouchExit", hit.point, SendMessageOptions.DontRequireReceiver);
                      }
                      
                  }
         
             }
     
 #endif
         
         
         
         
         
     
         }
 }

Its a script for detection touch inputs, for when u play the game on touch devices.
This script is attached to the main camera, and when i click a 2d object with the layermask “touchinputmash”, and a script saying something like: void OnTouchDown () {
print(“NICE!”);
}

But when i click my desired 2d object i get the warning: NullReferenceException: Object reference not set to an instance of an object
TouchInput.Update () (at Assets/Scripts/TouchInput.cs:33).

So its something with the line: recipient = hit.transform.gameObject;

But i cant figure out what.

it looks like you’re missing out hit in your raycast