Bullet mouse position problem

So when I try to fire bullets using this code for the bullets at a close range to something my bullets get displaced than anything

https://gyazo.com/8a4065399092d4dd6948ebcc93543361

local BarrelPosition = self.WeaponTool.Barrel.Position
local Bullet = game.ReplicatedStorage.Bullet:Clone()
								
Bullet.CFrame = CFrame.new(BarrelPosition)
Bullet.CFrame = CFrame.new(Bullet.Position, Mouse.Hit.p) * CFrame.new(0, 0, -6)
				
local bv = Instance.new("BodyVelocity", Bullet)
bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
bv.Velocity = Mouse.Hit.LookVector * 1000;
Bullet.Parent = game.Workspace.BulletStorage

I only do the last CFrame statement to displace the bullet slightly infront of the barrel

1 Like

So first your bullet is placed according to this

Bullet.CFrame = CFrame.new(Bullet.Position, Mouse.Hit.p)

which is positioned same as the barrel, but oriented to where the mouse points. When you’re really close to something this is usually not even close to the direction the barrel is pointing, because the barrel is in the lower right and the mouse is somewhere in the center of the screen.

You then move it 6 studs forwards with this

* CFrame.new(0, 0, -6)

which makes the problem even worse, because it’s “forwards” according to the bullet which is pointing the wrong direction.

I solved it by just ignoring everything in work space so that my mouse position can’t be altered