Hey! I’m working on a custom gun system, and I’m trying to get the gun to rotate properly with the arms. However, the gun is welded to the UpperTorso of the character - I’m using Headstackk’s gun animating method, which allows for the gun to be moved freely.
However, the gun doesn’t follow the arms accurately, and the gun is offset from its intended position, which should be in the player’s arms.
Headstackk also seems to have the same issue as me, which you can find below:
Additionally, this post appears to describe the same issue:
Is there any math/offset things I could do to get the gun to be positioned properly with the arms?
Here’s the relevant code that moves the arms & gun:
-- Added code to make the snippet "function" local Direction = HumanoidRootPart.CFrame:ToObjectSpace(workspace.CurrentCamera.CFrame).LookVector local AngleX = math.asin(Direction.Y) local AngleY = math.asin(Direction.X) -- local AngleOffset = CFrame.Angles(AngleX, AngleY, 0) Character.Head.Neck.C0 = OriginalNeckC0 * AngleOffset Character.LeftUpperArm.LeftShoulder.C0 = OriginalLeftShoulderC0 * AngleOffset Character.RightUpperArm.RightShoulder.C0 = OriginalRightShoulderC0 * AngleOffset Character.UpperTorso.Tool.C0 = AngleOffset
For reference, OriginalNeckC0, LeftShoulderC0, and RightShoulderC0 are values from the motor6d’s C0 when the player spawns, which is saved to the variables.
Thanks in advance!