What I want to achieve is pretty simple. An accurate raycast from origin (character head) to mouse hit position.
The raycast is perfectly accurate when using the gun in first person (aiming down sights), but is not accurate when firing the gun in third person.
I have tried using Mouse.hit, Mouse.hit.p, mouse.UnitRay.Direction, and Mouse.Hit.LookVector for raycast direction (randomly trying things out) to see if any of this would work, everything besides mouse.UnitRay.Direction has exhibited undesirable behavior. I am unsure what to do now.
here is the relevant bit of code for the raycast.
local unitRayDirection = Mouse.UnitRay.Direction;
local hitObject = workspace:Raycast(Character.Head.Position, unitRayDirection * maxRange, RayCastFilterObjects, RayCastGunFilter); -- just ignore the filters