Help with raycasting rays not going where clicking

Im trying to make a gun for the first time and Im having trouble with the rays not going where im clicking. Can someone tell me whats wrong? I need help.
Ive tried mouse.hit.position but that wont work either. everything is in the local script.

I click and it just says nil because its not hitting anything. when the part that creates the raycast is inside another part and I click it can print that or if im walking sometimes it can also print that its hitting me somehow but thats about it.

You need to multiply the directional vector with a range (magnitude), which represents the distance of the ray.

First person to give me an answer that fixes this thank you.