FPS gun and arms doesn't aligning correctly


Hello! As you can see in the title and the video above, the gun and the arm are not aligned properly. when I look up (or down), the gun overlaps the hand weirdly.
I have no idea. how can I solve this?

local neckC0 = CFrame.new(0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1);
local waistC0 = CFrame.new(0, 0.2, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1);
local rShoulderC0 = CFrame.new(0.712, 0.634, -0.008, 1, 0, 0, 0, 1, 0, 0, 0, 1);
local lShoulderC0 = CFrame.new(-0.712, 0.634, -0.008, 1, 0, 0, 0, 1, 0, 0, 0, 1);
local rShoulderC1 = CFrame.new(0.296, 0.409, -0.01, 1, 0, 0, 0, 1, 0, 0, 0, 1);
local lShoulderC1 = CFrame.new(-0.296, 0.409, -0.01, 1, 0, 0, 0, 1, 0, 0, 0, 1);


game:GetService("ReplicatedStorage").tiltAt.OnServerEvent:Connect(function(player, theta)
	if not player.Character.Head:FindFirstChild("Neck") then return end
	local neck = player.Character.Head.Neck
	local waist = player.Character.UpperTorso.Waist
	local rShoulder = player.Character.RightUpperArm.RightShoulder
	local lShoulder = player.Character.LeftUpperArm.LeftShoulder

	neck.C0 = neckC0 * CFrame.fromEulerAnglesYXZ(theta*.75, 0, 0);
	waist.C0 = waistC0 * CFrame.fromEulerAnglesYXZ(theta*.25, 0, 0);
	rShoulder.C0 = rShoulderC0 * CFrame.fromEulerAnglesYXZ(theta*.75, 0, 0);
	lShoulder.C0 = lShoulderC0 * CFrame.fromEulerAnglesYXZ(theta*.75, 0, 0);
end)

^
This is server side character tilting script.
Players send tilt angles to the server every frame.(I referenced this tutorial)

The gun is connected to the head by motor6d. Maybe that’s why it doesn’t seem to work properly.

Please help!!

What part Is the gun welded to?

The gun is moving relative to the head. But, the arms aren’t moving relative to the head, causing that offset bug. You can either weld the gun to the player’s arm, or match the arms to move relative to the head as well.

the gun has not welded, but it connected to the head with motor6d

I think s,o How can I fix the offset bug? I don’t know much about cframe and motor6d.

A simple alternative could be welding the gun to the arm instead, and let the arm take control of the gun. Specifically, the arm that is holding the handle.

Welding a gun to an arm makes it uncomfortable when animating, so I prefer welding to parts other than the arm. (I animate with a blender)

Anyway, I was going to write a script to get my arms moving around my head to fix the offset bug, but I decided to just fix the gun to my torso. Thank you for your help!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.