Arm Follow Camera Script, need help to fix a problem

Hello, i’m looking for help to fix a problem in my script because i can’t find any solution

what i do is make the arm follow the camera instead of the torso moving it with C0 but when the character starts rotating the arm starts shaking and i don’t want that but I don’t know how to fix it

here a video:

here my code, is normally in a renderstepped loop:

local Camera = workspace.CurrentCamera
	local Character = LocalPlayer.Character

	if not Character then
		return
	end

	local Humanoid = Character:WaitForChild("Humanoid")

	local Torso = Character:WaitForChild("Torso")
	local Head = Character:WaitForChild("Head")
	local RightArm = Character:WaitForChild("Right Arm")
	local LeftArm = Character:WaitForChild("Left Arm")
	local Root = Character:WaitForChild("HumanoidRootPart")

	if RightArm	then
		RightArm.LocalTransparencyModifier = RightArm.Transparency
	end

	if LeftArm then
		LeftArm.LocalTransparencyModifier = LeftArm.Transparency
	end

	if not Humanoid or Humanoid.Health == 0 or not Head or not Torso or not Root then
		return
	end

	local RightShoulder = Torso:WaitForChild("Right Shoulder")
	local LeftShoulder = Torso:WaitForChild("Left Shoulder")

	local CameraIsFirstPerson = (Character.Head.Position - Camera.CFrame.Position).magnitude < 1

	if RightShoulder then

		RightShoulder.C0 = (Camera.CFrame * CFrame.new(1, -1, -1)):ToObjectSpace(Torso.CFrame):Inverse() * CFrame.Angles(0, math.rad(90), 0)
		--RightShoulder.C0 = CFrame.new(1, 0.5, 0) * CFrame.Angles(0, math.pi/2, 0)

	end

	if LeftShoulder then

		LeftShoulder.C0 = (Camera.CFrame * CFrame.new(-1, -1, -1)):ToObjectSpace(Torso.CFrame):Inverse() * CFrame.Angles(0, math.rad(-90), 0)

	end

any help is welcome, thank you


here the video of the problem

Try this

local RunService	= game:GetService('RunService')

local Camera = workspace.CurrentCamera
local Character = game.Players.LocalPlayer.Character

if not Character then
	return
end

local Humanoid = Character:WaitForChild("Humanoid")

local Torso = Character:WaitForChild("Torso")
local Head = Character:WaitForChild("Head")
local RightArm = Character:WaitForChild("Right Arm")
local LeftArm = Character:WaitForChild("Left Arm")
local Root = Character:WaitForChild("HumanoidRootPart")

local RightShoulder = Torso:WaitForChild("Right Shoulder")
local LeftShoulder = Torso:WaitForChild("Left Shoulder")

local SavedRightShoulderC0 = RightShoulder.C0
local SavedLeftShoulderC0 = LeftShoulder.C0

while true do
	local DeltaTime = RunService.RenderStepped:Wait()
	
	if RightArm	then
		RightArm.LocalTransparencyModifier = RightArm.Transparency
	end

	if LeftArm then
		LeftArm.LocalTransparencyModifier = LeftArm.Transparency
	end

	if not Humanoid or Humanoid.Health == 0 or not Head or not Torso or not Root then
		return
	end

	local CameraIsFirstPerson = (Character.Head.Position - Camera.CFrame.Position).magnitude < 1

	if RightShoulder then
		RightShoulder.C0 = RightShoulder.Part0.CFrame:ToObjectSpace(Camera.CFrame * SavedRightShoulderC0) * CFrame.new(0,-1,0)
	end

	if LeftShoulder then
		LeftShoulder.C0 = LeftShoulder.Part0.CFrame:ToObjectSpace(Camera.CFrame * SavedLeftShoulderC0) * CFrame.new(0,-1,0)
	end
end

Hello, thank you for replying and sorry for the late reply i was sleeping but i try what you do and it still happen but i discover what make this happen is because of the autorotate of the humanoid looping in the heartbeat because when i make my code loop in the heartbeat it look bad for the camera but good with shiftlock or first person

1 Like