Viewmodel not locking onto the camera

I am trying to make a viewmodel that makes the player’s arms and legs follow the camera when you are in first person, but i disabled the character locking when you go to first person which causes it to not follow the camera when i disable the shiftlock.

The script:

	local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")

local player = Players.LocalPlayer
local character = player.Character
local root = character:WaitForChild("HumanoidRootPart")
local humanoid = character:WaitForChild("Humanoid")
local camera = game.Workspace.CurrentCamera

local torso = character:FindFirstChild("Torso")
local leftArm = character:FindFirstChild("Left Arm")
local rightArm = character:FindFirstChild("Right Arm")
local leftLeg = character:FindFirstChild("Left Leg")
local rightLeg = character:FindFirstChild("Right Leg")

local leftShoulder = torso:FindFirstChild("Left Shoulder")
local rightShoulder = torso:FindFirstChild("Right Shoulder")
local leftHip = torso:FindFirstChild("Left Hip")
local rightHip = torso:FindFirstChild("Right Hip")

local defaultLeftArmC1 = leftShoulder.C1
local defaultRightArmC1 = rightShoulder.C1
local defaultLeftLegC1 = leftHip.C1
local defaultRightLegC1 = rightHip.C1

local defaultLeftArmC0 = leftShoulder.C0
local defaultRightArmC0 = rightShoulder.C0
local defaultLeftLegC0 = leftHip.C0
local defaultRightLegC0 = rightHip.C0

local spring = require(script.Spring)

local mouseDeltaDivision = 200

local swayOffset = CFrame.new()
local movementOffset = CFrame.new()

local swaySpring = spring.create()
local movementSpring = spring.create()

local transparency = 0
local sped = 0

local function setTransparency(part)
	if part and part:IsA("BasePart") and (part.Name == "Left Arm" or part.Name == "Right Arm" or part.Name == "Left Leg" or part.Name == "Right Leg") then
		part.LocalTransparencyModifier = transparency

		part:GetPropertyChangedSignal("LocalTransparencyModifier"):Connect(function(property)
			part.LocalTransparencyModifier = transparency
		end)
	end
end

local function inFirstPerson()
	local dist = (camera.CFrame.Position - (root.Position + Vector3.new(0, 1.5, 0))).Magnitude
	return dist < 1
end

local function getBobbing(addition, speed, modifier)
	return math.sin(tick() * addition * speed) * modifier
end

local function renderStepped(dt)
	local speed = 1.5 * (humanoid.WalkSpeed / 16)
	local modifier = 4

	local mouseDelta = UserInputService:GetMouseDelta()
	local walkCycle = Vector3.new(getBobbing(10, speed, modifier), getBobbing(5, speed, modifier), 0) * dt

	swaySpring:shove(Vector3.new(mouseDelta.x / mouseDeltaDivision, mouseDelta.y / mouseDeltaDivision))

	if script:GetAttribute("WalkCycle") == true then
		movementOffset = movementSpring:update(dt)
	else
		movementOffset = CFrame.new()
	end

	if script:GetAttribute("ViewmodelSway") == true then
		swayOffset = swaySpring:update(dt)
	else
		swayOffset = CFrame.new()
	end

	local movementCF = CFrame.new()
	movementCF = CFrame.new(movementOffset.y, movementOffset.x, movementOffset.z)

	if humanoid.MoveDirection.Magnitude > 0 then
		movementSpring:shove(walkCycle * sped / (humanoid.WalkSpeed - 1))
	else
	movementSpring:shove(Vector3.new())
	end

	if inFirstPerson() then
		transparency = script:GetAttribute("ArmTransparency")

		local torsoX, torsoY, torsoZ = torso.CFrame:ToEulerAnglesYXZ()
		local cameraX, cameraY, _ = camera.CFrame:ToEulerAnglesYXZ()
		local viewmodelOffset = script:GetAttribute("ViewmodelOffset")

		local torsoRot = CFrame.Angles(0, torsoY, torsoZ)
		local cameraPos = CFrame.new(viewmodelOffset.X, viewmodelOffset.Y, -viewmodelOffset.Z)
		local cameraRot = CFrame.Angles(0, -cameraY, 0)
		local swayCF = CFrame.Angles(swayOffset.y, swayOffset.x, swayOffset.x / 2)
		
		local camCF = camera.CFrame * cameraPos * cameraRot * torsoRot * swayCF * movementCF

		rightShoulder.C0 = torso.CFrame:inverse() * (camCF * CFrame.Angles(0, math.rad(90), 0) * CFrame.new(0, -1, 1))
		leftShoulder.C0 = torso.CFrame:inverse() * (camCF * CFrame.Angles(0, math.rad(-90), 0) * CFrame.new(0, -1, 1))
		rightHip.C0 = torso.CFrame:inverse() * (camCF * CFrame.Angles(0, math.rad(90), 0) * CFrame.new(0, -2, 1))
		leftHip.C0 = torso.CFrame:inverse() * (camCF * CFrame.Angles(0, math.rad(-90), 0) * CFrame.new(0, -2, 1))
	else
		transparency = 0
		
		local motors = rightShoulder and leftShoulder and rightHip and leftHip
		--local defc1s = defaultLeftArmC1 and defaultRightArmC1 and defaultLeftLegC1 and defaultRightLegC1
		local defc0s = defaultLeftArmC0 and defaultRightArmC0 and defaultLeftLegC0 and defaultRightLegC0
		if motors and defc0s then
			rightShoulder.C0 = defaultRightArmC0
			leftShoulder.C0 = defaultLeftArmC0
			rightHip.C0 = defaultRightLegC0
			leftHip.C0 = defaultLeftLegC0
		end
	end
end

for _, v in pairs(character:GetChildren()) do
	setTransparency(v)
end

RunService.RenderStepped:Connect(renderStepped)
character:WaitForChild("Humanoid").Running:Connect(function(Speed)
	if Speed ~= sped then
		sped = Speed
	end
end)

Viewmodels are not always made using the characters real arms, often they are adding in separate and given the same shirt

But for this exact issue sorry I can’t help you since I always do a separate viewmodel