Bullets are not going directly to mouse position

Hi, I recently made a gun system to my game, but I can’t fix a problem; bullets sometimes are not going directly to mouse position

Server Script(only the main part)

local debounce = false
local firerate = 0.2
local damage = 25
local maxAmmo = 8
local ammo = 8
local reloading = false
local equipped = false

script.Parent.Equipped:Connect(function()
	equipped = true
end)

script.Parent.Unequipped:Connect(function()
	equipped = false
	
end)

-- This function gets the mouse position from local script --
script.Parent.GetMousePos.OnServerEvent:Connect(function(player, mouse)
	script.Parent.Value.Value = mouse
	if equipped == true then
	player.PlayerGui.AmmoGui.Ammo.Text = ammo
	player.PlayerGui.AmmoGui.GunName.Text = script.Parent.Name 
	end
end)

-- Damage indicator I added --
local function damageIndicatorPos(object)
	for i = 1, 25, 1 do
		object.ExtentsOffset = object.ExtentsOffset + Vector3.new(0,0.06,0)
		object.TextLabel.TextTransparency = object.TextLabel.TextTransparency + 0.04
		object.TextLabel.TextStrokeTransparency = object.TextLabel.TextStrokeTransparency + 0.04
		wait()
	end
object:Destroy()
end

-- Main script --
script.Parent.Activated:Connect(function()
if reloading == false then
	if debounce == false then
		if ammo > 0 then
			ammo = ammo - 1
			print(ammo)
			script.Parent.ShotEffectPos.Smoke.Enabled = true
			script.Parent.BulletPos.Shot:Play()
			script.Parent.SlideA.Transparency = 1
			script.Parent.SlideB.Transparency = 0
			local bullet = game.ServerStorage.Bullet:Clone()
			local bullet2 = game.ServerStorage.ChamberBullet:Clone()
			bullet2.Parent = workspace
			bullet2.CFrame = script.Parent.ChamberBulletPos.CFrame
			bullet2.Velocity = script.Parent.ChamberBulletPos.CFrame.LookVector * 50
			bullet.Parent = workspace
			bullet.CFrame = CFrame.new(script.Parent.BulletPos.Position, script.Parent.Value.Value.Position)
			bullet.Velocity = script.Parent.Value.Value.LookVector * 650
			bullet.CanCollide = false
			bullet.Touched:Connect(function(hit)
			if hit.Parent then
				if hit.Parent ~= script.Parent and hit.Parent ~= script.Parent.Parent then
					bullet:Destroy()
						if hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChild("Head") then
								hit.Parent.Humanoid:TakeDamage(damage)
								bullet:Destroy()
								local damageIndicator = game.ServerStorage.BillboardGui:Clone()
								damageIndicator.Adornee = hit.Parent.Head
								damageIndicator.TextLabel.Text = damage
								damageIndicator.Parent = hit.Parent
								damageIndicatorPos(damageIndicator)
						end
					end
				end
			end)
		debounce = true
		wait(0.05)
		script.Parent.SlideA.Transparency = 0
		script.Parent.SlideB.Transparency = 1
		wait(firerate)
		script.Parent.ShotEffectPos.Smoke.Enabled = false
		debounce = false
		end
		end
	end
end)

May you explain more on “sometimes” not going to mouse position, and our you just clicking then moving your mouse fast away?

What do you mean? There’s a bullet that moves, not the mouse…

I said when you fire you move the mouse and it looks like it’s not going to the mouse position.

No, I am not moving the mouse, and I still need to aim near NPC to shot it(its not the bullet drop)

Also the problem may be this, when it doesn’t go to the mouse is your camera to the right of left of the player. Because when I used to do simple raycast system when I was younger I remember the bullet always being off by one stud when I was to the left or right of the player

Could you send a video or Mp4 of what’s happening so it makes it a little easier to help out

Can it be a screenshot?

(30 chars)

A video would be nice but sure, if you want to take easy little 7 second gifs you can get gyazo. I use it all the time!

I don’t have anything to make a video(yea right), I can send link to the game

Lava Game

That would be amazing!

30 charrrrrrrrrs

The game is currently closed I don’t have perms

I made it public for some time, you can join now

I don’t really want to make character following mouse pos, but thanks for help…

Like I said In game it only happens when your camera is on weird angles that my only suggestion is locking it in shiftlock or idk

The sniper has long barrel, and the character moves hands when moving, so it rotates the bullet too, I think I will make custom animations that are not moving hands, and first person lock when aiming with sniper