Viewmodel bugs | Sway/bobbing (ego's tutorial)

Hey all,

I’ve been reading and following Egomoose’s tutorial on viewmodels, and I am looking to setup my own system of using animations rather than calculating the c1 for the arms… I’m trying to get the arms to sway with the gun right now:

Current Code:

local function updateArm(self, key)
    if (self[key]) then
        local shoulder = self.isR15 and self.viewModel["Head"][key.."Shoulder"]
        local cf = self.weapon[key].CFrame * CFrame.Angles(0, 0, 0)
        shoulder.C1 = shoulder.C1 --i don't know what to do here
    end
end

Original code:

local function updateArm(key)
    -- get shoulder we are rotating
    local shoulder = viewModel[key.."UpperArm"][key.."Shoulder"];
    -- calculate worldspace arm cframe from Right or Left part in the weapon model
    local cf = weapon[key].CFrame * CFrame.Angles(math.pi/2, 0, 0) * CFrame.new(0, 1.5, 0);
    -- update the C1 value needed to for the arm to be at cf (do this by rearranging the joint equality from before)
    shoulder.C1 = cf:inverse() * shoulder.Part0.CFrame * shoulder.C0;
end

Tutorial: The First Person Element Of A First Person Shooter

Here’s an attached place file: FPS_Ego.rbxl (413.7 KB)

Thanks

Hi, I have a similar problem with the same egomoose system, I wanted to add animations to the viewmodel but I realized that the arms were practically welded to two reference blocks found in the weapon model called left and right.
I tried to disconnect them but this led me to more problems since when disconnecting the reference blocks with my hands the viewmodel simply did not move, not even to aim and I realized something else and that is that the blocks are welded to the weapon, thus making the weapon the only thing that moves.
any way to make the view model follow the camera and also when pointing and being able to make animations without having the reference blocks?.