Raw Image or Render Texture block MouseOver (New to unity)

(Btw Im new-ish to unity, only been using it for just over a month) So I have an issue with getting a door to open, and I can imagine this will cause problems with further functions of the game.

I have a code that works perfectly fine, the door opens when the render texture raw image is turned off and the target texture from the camera is removed. However when it is on the prompt to open the door does not appear and the door cannot be opened

Heres the code for the Raycast for the Player:

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

public class PlayerCasting : MonoBehaviour
{
    public static float DistanceFromTarget;
    public float ToTarget;

    
    void Update()
    {
        RaycastHit Hit;
        if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.forward), out Hit)) ;
        {
            ToTarget = Hit.distance;
            DistanceFromTarget = ToTarget;
        }
    }


}

Heres the code for door:

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

public class DoorOpen: MonoBehaviour
{
    public float TheDistance;
    public GameObject ActionDisplay;
    public GameObject ActionText;
    public GameObject TheDoor;
    public AudioSource BathroomDoorSound;

    void Update()
    {
        TheDistance = PlayerCasting.DistanceFromTarget;
    }

    void OnMouseOver ()
    {
        if (TheDistance <= 2)
        {
            ActionDisplay.SetActive (true);
            ActionText.SetActive (true);
        }

        if (Input.GetButtonDown("Action"))
        {
            if (TheDistance <= 2)
            {
                this.GetComponent<BoxCollider>().enabled = false;
                ActionDisplay.SetActive(false);
                ActionText.SetActive(false);
                TheDoor.GetComponent<Animation>().Play("FirstDoorOpen");
                BathroomDoorSound.Play();
            }
        }
    }

    void OnMouseExit()
    {
        ActionDisplay.SetActive(false);
        ActionText.SetActive(false);
    }
}

Thanks for reading, it may be a really easy fix but im not sure and if you need anything else just ask.

Possibly the Canvas group is blocking raycasts, if you add a Canvas Group to your image and disable Block Raycasts, that might fix it…

https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/class-CanvasGroup.html