Gun isnt aiming towards mouse

fixed video:
the white dot is where the gun is pointing but the bullets dont go there for some reason
the center of the crosshair is where the mouse is
im using fastcast to get the bullets moving

code to point arms to mouse:

local rightX, rightY, rightZ = fakeArms.RootPart["Right"].C0:ToEulerAnglesYXZ()
fakeArms.RootPart["Right"].C0 = (fakeArms.RootPart["Right"].C0 * CFrame.Angles(0, 0, -rightZ)) * CFrame.Angles(0, 0, math.asin((mouseHit.p - fakeArms.RootPart.CFrame.p).unit.y))

local leftX, leftY, leftZ = fakeArms.RootPart["Left"].C0:ToEulerAnglesYXZ()
fakeArms.RootPart["Left"].C0 = (fakeArms.RootPart["Left"].C0 * CFrame.Angles(0, 0, -leftZ)) * CFrame.Angles(0, 0, math.asin((-mouseHit.p - -fakeArms.RootPart.CFrame.p).unit.y))

the fakeArms are a copy of the player’s arms with the RootPart being a copy of the torso (using fake arms to add movement and recoil)

Make sure whatever method you’re using to obtain the mouse’s 3D hit position properly accounts for the topbar inset of 36 pixels

im using plr:GetMouse().Hit from the client to the server
i dont know if that counts for the inset

switched it over to UserInputService:GetMouseLocation() then minused 36 from the y
but the dot is still off from the center of the crosshair

image

fixed by guessing an offset

local mousePos = Vector3.new(mouseHit.p.X, mouseHit.p.Y - 10, mouseHit.p.Z)

correction: only fixed it when the mouse was on a part or the mouse when directly infront of the character

video:
white dot in the center of the crosshair is the mouse and where the bullets should pass through

the gun uses two attachments to fire
one attachment tells fastcast where to start
the other tells fastcast which direction to go

these two attachments are right next to each other going in the direction of the barrel not the mouse
if your camera isnt behind the character and you fire with your mouse to the side (like in the video) it wouldnt shoot where it should

any way to move towards the mouse?

updated code:

local mousePos = Vector3.new(mouseHit.p.X, mouseHit.p.Y - 10, mouseHit.p.Z)
local right = fakeArms.RootPart["Right"]
local left = fakeArms.RootPart["Left"]
local rootPart = fakeArms.RootPart
	
local rightX, rightY, rightZ = right.C0:ToEulerAnglesYXZ()
right.C0 = (right.C0 * CFrame.Angles(0, 0, -rightZ)) * CFrame.Angles(0, 0, math.asin((mousePos - rootPart.CFrame.p).unit.y))

local leftX, leftY, leftZ = left.C0:ToEulerAnglesYXZ()
left.C0 = (left.C0 * CFrame.Angles(0, 0, -leftZ)) * CFrame.Angles(0, 0, math.asin((-mousePos - -rootPart.CFrame.p).unit.y))

fixed with a solution i dont want to give away