Raycast bugging out

I’m working on my ray cast script. Everything works fine but it bugs out when i try to shoot the object(Lightning bolt) towards a ignore object (The grey part in the following video) I want it to go directly where the mouse is, it does until I aim it at the ignore part. The lightning bolt just goes UP. Example video;


code; image
Any help would be useful

What is MousePosition defined as?