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
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))