Bullets starting from the wrong position

for some reason it only happens whenever i move backwards in the range of degrees in front of me and in third person

video

External Media

when i remove the script that makes you look at your cursor it works completely fine without this happening
part of script here:

game:GetService("RunService").RenderStepped:connect(function()
	torso = character:FindFirstChild("Torso")
	if inputservice.KeyboardEnabled == false then
		ismobile = true
	else
		ismobile = false
	end
	local isdashing = false
	local tracks = player.Character.Humanoid.Animator:GetPlayingAnimationTracks()
	if tracks then
		for _, track in ipairs(tracks) do
			if track.Priority == Enum.AnimationPriority.Action4 then
				isdashing = true
			end
		end
	end
	if isdashing == false and torso and ismobile == false and player.Character.Humanoid.Health > 0 then
		torsoPos = torso.Position
		dir = (mouse.Hit.Position - torsoPos).unit
		torso.CFrame = CFrame.new(torsoPos) * CFrame.Angles(0, atan2(dir.X, dir.Z) + pi, 0)
	end
end)

im going to sleep now so i hope i see some potential fixes

The script here doesn’t really provide any clue on how you position the bullet. To my understanding, this script just adjusts your character’s torso CFrame so that it looks at the mouse or where the target is.

Can you show us the script that casts and visualises the bullet so that we can debug your code?

My bad lemme do that when i get back on

sooo i somehow fixed it by replacing the runservice thing with a while true do loop idk how that works