Moving Arms Around Character Using Motor6D for Guns

Hello! I’ve been having issues getting my weapon system to follow the mouse accurately. I’ve narrowed down the issue to the arm-movement portion, and I understand why it’s doing it…i’m just unsure of how to proceed. Here’s the specifics, ignore overloading functions pls:

--LocalScript inside the tool

--Creating AlignOrientation for character/HumanoidRootPart to follow mouse as well
local function setupOrientation()
	CHARACTER:WaitForChild("Humanoid").AutoRotate = false
	local rootAttach ="Attachment")
	rootAttach.Parent = HRP
	rootAttach.Position = HRP.Position

	rootAlignOrient = script.AlignOrientation:Clone()
	rootAlignOrient.PrimaryAxis = HRP.Position
	rootAlignOrient.PrimaryAxisOnly = true
	rootAlignOrient.Attachment0 = rootAttach
	rootAlignOrient.Parent = HRP

--Update HRP and arms positioning
mover = MOUSE.Move:Connect(function()
		rootAlignOrient.CFrame = MOUSE.Hit,0,0),0,0)--CFrame.Angles(math.rad(45),0,0)
		local neckJointReturn = worldCFrame(neckJoint,MOUSE.Hit)
		local rightX, rightY, rightZ = TORSO["Right Shoulder"].C0:ToEulerAnglesYXZ()
		TORSO["Right Shoulder"].C0 = (TORSO["Right Shoulder"].C0 * CFrame.Angles(0, 0, -rightZ)) * CFrame.Angles(0, 0, math.asin((MOUSE.Hit.p - MOUSE.Origin.p).unit.y))

		local leftX, leftY, leftZ = TORSO["Left Shoulder"].C0:ToEulerAnglesYXZ()
		TORSO["Left Shoulder"].C0 = (TORSO["Left Shoulder"].C0 * CFrame.Angles(0, 0, -leftZ)) * CFrame.Angles(0, 0, math.asin((-MOUSE.Hit.p - -MOUSE.Origin.p).unit.y))
		WEAPON_PARTS:WaitForChild("BodyMove"):FireServer(neckJointReturn, TORSO["Right Shoulder"].C0, TORSO["Left Shoulder"].C0)

--ServerScript for handing Server-Wide changes to player body
game:GetService("ReplicatedStorage"):WaitForChild("WeaponParts").BodyMove.OnServerEvent:Connect(function(player, newC0, rightArm, leftArm)
	player.Character:WaitForChild("Torso").Neck.C0 = newC0
	player.Character.Torso["Right Shoulder"].C0 = rightArm
	player.Character.Torso["Left Shoulder"].C0 = leftArm

In the gifs I show how the gun rotates in an almost spherical way around the mouse position. I assume this is from the use of Motor6D C0s to move the arms. I don’t entirely hate the way it rotates in a spherical shape, but when you go to the extremes of the camera angles, it really gets inaccurate: it doesn’t even point remotely close to the mouse.

I’m really stuck on how to alleviate this without doing the FakeArms thing like other systems do. Any help appreciated, thanks!

1 Like

Hi bro, have you solved the spherical shape issue now? I have met the same problem. I am trying to figure out this issue as per the solution of Roblox`s weapon-kit but the system of official source is so complex…