So I’m currently creating a game that requires that I can tap on 2D sprites to either pick them up or activate them. My scripting works for 3D objects but for some reason doesn’t seem to work with 2D objects. Using raycasts currently but will rework my coding so that I can work with 2D. Thank you so much for your help!

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;

public class Interactables: MonoBehaviour
{
    Ray ray;
    RaycastHit hit;

    private float distp;
    public float maxdist;

    private bool ispaused;
    bool open = false;

    public static String trigname;
    public static bool radiohit = false;
    private Vector3 v1;

    private int hitnum = 0;

    // Use this for initialization
    void Start()
    {
        maxdist = 5f;
    }

    // Update is called once per frame
    void Update()
    {
        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        Clickers();
        ispaused = CharacterSettings.paused;
        if (open == true)
        {
            //close after far away enough
        }
    }

    private void Clickers()
    {
        if (Input.GetMouseButtonDown(0))
        {
            if (Physics.Raycast(ray, out hit, 100.0f))
            {
                if (hit.transform != null)
                {
                    //Debug.Log(hit.transform.tag);
                    if (ispaused == false)
                    {
                        distp = Vector3.Distance(transform.position, hit.transform.position);
                        //Here goes the selectable items
                        if (distp <= maxdist)
                        {
                            Note();
                            Door();
                            Battery();
                            conversation();
                            radio();
                        }
                    }
                }
            }
        }
    }

    private void Note()
    {
        if (hit.transform.tag == "Note")
        {
            //Activate Note Trigger
        }
    }


    private void Door()
    {
        if (hit.transform.tag == "Door")
        {
            if (open == false)
            {
                //hit.transform.parent.transform.Rotate(0.0f, 120.0f, 0.0f);
                hit.transform.parent.transform.rotation = Quaternion.RotateTowards(hit.transform.parent.transform.rotation, new Quaternion(0.0f, 10.0f, 0.0f, 0.0f), 10 * Time.deltaTime);
                open = true;
            }
            else if(open == true)
            {
                hit.transform.parent.transform.Rotate(0.0f, -120.0f, 0.0f);
                open = false;
            }
        }
    }

    private void Battery()
    {
        if (hit.transform.tag == "Battery")
        {
            Flashlight.battery++;
            Destroy(hit.transform.gameObject);
        }
    }

    private void conversation()
    {
        //Use Dialogue Trigger
    }


    private void radio()
    {
        if (hit.transform.name == "Radio" && hitnum == 0)
        {
            hitnum = 1;
            hit.transform.GetComponent<AudioSource>().Play();
        }
        else if (hitnum == 1)
        {
            hit.transform.GetComponent<AudioSource>().Pause();
            hitnum = 2;
        }
        else if (hitnum == 2)
        {
            hit.transform.GetComponent<AudioSource>().UnPause();
            hitnum = 1;
        }
    }
}

Use Physics2D.Raycast for 2D objects.