Basically, I'm making a gun. When you click the mouse, it raycasts to where you click with a Y axis of 3 so it just keeps going (not down or up). I'm using a BodyVelocity to get it to go from the gun forward at a constant speed, but because of the way a BodyVelocity works I have to have all of the shots go the same distance so the speed is maintained throughout, so I have to calculate PAST the endpoint of the ray. My problem is that I can't seem to figure out how to do that. It doesn't always fire to where the mouse is, and it mostly messes up when the mouse is near any object. (I know the ray is working, because if I cut out the BodyVelocity and just place the shot at the endpoint it works perfectly).
Here's how I'm calculating the velocity of the BodyVelocity:
--pos is the endpoint of the ray that is cast.
local v3=(Vector3.new(gunhandle.CFrame.X,3,gunhandle.CFrame.Y)-pos).unit
newshot.BodyVelocity.velocity = -(Vector3.new(0,3,0) + v3*200)
Thanks, --MightyWanderer

2 comments
This isn't raycasting
It includes raycasting, since the endposition is required for the calculation.