What you need first is to obtain the point of origin and the point of target, your origin being the end of the gun barrel and the target being the point of your mouse hit.
Then you will need to cast a ray from the origin to the target
Lastly you place the bullet between the origin (end of gun barrel) and the ray hit position.
Let me help you with a demo,
If you put 3 parts in workspace and call them origin, target and bullet respectively and put a cylindermesh in the bullet you can start off with this piece of code:
origin = game.Workspace.origin
target = game.Workspace.target
bullet = game.Workspace.bullet
ignore = {} -- ignore list, put whatever you need in here that needs to be ignored
ray = Ray.new(origin.CFrame.p,(target.CFrame.p - origin.CFrame.p).unit * 150) -- initialize ray class from origin to target (the 150 is the max. range of the ray)
hit, position = game.Workspace:FindPartOnRayWithIgnoreList(ray, ignore) -- cast the ray (hit = part that the ray hit, position = the position of where the ray hit)
distance = (origin.Position-position).Magnitude
bullet.Size = Vector3.new(distance,0.5,0.5)
bullet.CFrame = CFrame.new(origin.Position,target.Position)*CFrame.new(0,0,-distance/2)*CFrame.Angles(0,math.rad(90),0) -- angles is to correct the orientation for the cylinder mesh
After that you should shrink the bullet.
I hope you can get started with this.