Attaching raycast beginning to gun?

So, i have been working on a gun this week, and for some the bullet wont stay attached to the gun. Is there a way i can fix this?

I want it so the beginning of the ray will be attached to the gun until the gun is deleted.

Thanks!

Here:
The Error

That’s probably because you’re using a server script.

Ok, but how would i fix it? It should also be visible for the server…

You can replicate it across clients

You have a tutorial for me? I dont really know what youre trying to say.