How to make the players arms move only vertically?

Hello, thank you for coming. I am working on a first person shooter and am trying to make the players arms move up and down with the camera. I’ve made a script which does that, but it makes the arms move sideways too. I’ve seen games like Survive and Kill the Killers in Area 51 !!! do what I am trying to do. Any help would be appreciated!

This is my script

local player = game.Players.LocalPlayer
local camera = game.Workspace.CurrentCamera
local humanoid = script.Parent:WaitForChild('Humanoid')
local humanoidRootPart = script.Parent:WaitForChild('HumanoidRootPart')
local rightShoulder = script.Parent.Torso:WaitForChild('Right Shoulder')
local leftShoulder = script.Paren.Torso:WaitForChild('Left Shoulder')
local runService = game:GetService('RunService')

runService.RenderStepped:Connect(function()
	local cameraCFrame = camera.CFrame
	rightShoulder.C0 = (cameraCFrame * CFrame.new(1, -1, -0.8)):ToObjectSpace(humanoidRootPart.CFrame):Inverse() * CFrame.Angles(0, math.pi / 2, 0)
	leftShoulder.C0 = (cameraCFrame * CFrame.new(-1, -1, -0.8)):ToObjectSpace(humanoidRootPart.CFrame):Inverse() * CFrame.Angles(0, -math.pi / 2, 0)
end)

this is what i use

local ShoulderJointBaseR = Player.Character.Torso["Right Shoulder"].C0
local ShoulderJointBaseL = Player.Character.Torso["Left Shoulder"].C0
local ShoulderJointBaseH = Player.Character.Torso.Neck.C0

Player.Character.Torso["Right Shoulder"].C0 = ShoulderJointBaseR * CFrame.Angles(0,0,math.asin((Mouse.Hit.Position - Mouse.Origin.Position).unit.Y))
Player.Character.Torso["Left Shoulder"].C0 = ShoulderJointBaseL * CFrame.Angles(0,0,-math.asin((Mouse.Hit.Position - Mouse.Origin.Position).unit.Y))
Player.Character.Torso.Neck.C0 = ShoulderJointBaseH * CFrame.Angles(-math.asin((Mouse.Hit.Position - Mouse.Origin.Position).unit.Y),0,0)

i dont understand the math, most of it was someone else’s code and i just messed with a few names and values.

1 Like

Thanks, one question, I tried the code and when I looked up the arms were too close to the camera, looking down would result in the arms looking detached. Is there a way to fix that?

im sure there is. i dont know it though, i never work with motor6d