Gluing arms rotation to Camera rotation

Hey guys, i’m currently making a leaning system and i’m try to get my fps arms to also rotate with the camera, here’s a video on what it looks like:


As you can see, it works but the arms don’t follow. Here’s my code for it so far:

Tool.Equipped:Connect(function()
	game.Players.LocalPlayer:GetMouse().Icon = "rbxassetid://117431027"
	Gui = Player.PlayerGui:WaitForChild("Gun")
	ToolEquipped = true
	Arms = game.ReplicatedStorage.Arms:Clone()
	Arms.Left.Transparency = 0
	Arms.Right.Transparency = 0
	Arms.Parent = game.Workspace
	ParticleEmitter = Arms.BulletEffect.ParticleEmitter
	GunName.Text = Tool.Name
	AmmoCount.Text = (Bullets .." / ".. Ammo)
	Gui.Enabled = true
	
	--Animation1
	ThirdPersonIdle()
	local AnimationIdle = Arms.Animations.Idle
	local AnimationController = Arms.AnimationController
	TrackIdle = AnimationController:LoadAnimation(AnimationIdle)
	TrackIdle:Play()
	
	local Connection = RunService.RenderStepped:Connect(function()
		cameraCFrame = workspace.CurrentCamera.CFrame 
		Arms.MainThing.CFrame = (cameraCFrame * CFrame.new(0,-2,-1.5) * CFrame.Angles(0,-45,0))
	end)
	--When uneqipping a tool
	Tool.Unequipped:Wait()
	Connection:Disconnect()
	Arms:Destroy()
	Gui.Enabled = false
	Reload = false
	ToolEquipped = false
	ThirdPersonTrackIdle:Stop()
end)

To attempt to glue the rotation, i’ve tried to do this:

local x, y, z = game.Workspace.CurrentCamera.CFrame:ToEulerAnglesXYZ()
Arms.MainThing.CFrame = (cameraCFrame * CFrame.new(0,-2,-1.5) * CFrame.Angles(0,-45 + z,0))

However, this is to no avail, can anyone please help me on this issue? Thanks in advance!

You could set your viewmodel’s head to the camera orientation

This is how I did it

workspace.Camera.CFrame *= CFrame.Angles(0, 0, -math.rad(count))
viewmodel.CameraBone.CFrame *= CFrame.Angles(0, 0, -math.rad(count))

The code would be in a renderstepped function. Every frame I would increase ‘count’ until its max
and you should get something like this:

https://gyazo.com/05978c31dba2b5dea9464005b7bee61f

You could just not do the count and Instead just replace ‘count’ with 45 or whatever your preferable rotation increment is