How to read note by pressing "E" using RayCast only?

So here is my problem … I made a gui texture like note that can be read when E is pressed ,but the command on read works on colider trigger script … actually I had to make 2 scripts to do this and I tought it would be better to do it raycast way with just one script based on main camera instead on gameobjects ,however I dont know how to write this script ,basicaly I am strugling for 5 hours to make it work I tryed to modify the existing script to work on raycast and taging the object I want to put ray on (the note) but it is not working or it is not raycasting corectly (aka when shoot from distance ray will show the gui “read” but when close to object it will not ,yet distance is set very near.

I know asking for scripts is cheating in a way but I am out of options …

Thanks whoever helps.

Basicaly I need this:

Script type - JavaScript

So far the best thing I was able to do was to make gui show on ray hit but raycasting angle was incorect or I messed up the code that I was making.

Now the best way to make it right is to say that I am not just gona copy paste the script if someone gives me as I never just did when I started programing ,very often I modify my scripts for diferent kinds of same or diferent actions with same references so it will be good for my learning.

You are probably looking for this. It sends a ray from the camera through any point of the screen you want (you can use the mouse position or the center of the screen to send the ray and if it collides with the note, then you read it).