Motor6D C1 making entire model move

Hey guys, thanks for reading.

I’ve been following the EgoMoose FPS tutorial (here’s the link: The First Person Element Of A First Person Shooter - Scripting Helpers) and I’m stuck on the part where he make the View Models arms stick to the gun. I am trying to create my own FPS engine with this as a base.

This is his script:

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

local function onUpdate(dt)
    viewModel.Head.CFrame = camera.CFrame;
    -- update every frame so the arms stay in place when the player aims down sights
    updateArm("Right");
    updateArm("Left");
end

--(Somewhere in his tutorial he links onUpdate to RenderStepped, Mine is just shorter)


--This is my script:
local function armPosition()
    local cf =  gunModelinUse.Right.CFrame * CFrame.Angles(math.pi/2,0,0) * CFrame.new(0,1.5,0)
    shoulder.C1 = cf:Inverse() * shoulder.Part0.CFrame * shoulder.C0

    local cf2 =  gunModelinUse.Left.CFrame * CFrame.Angles(math.pi/2,0,0) * CFrame.new(0,1.5,0)
    lshoulder.C1 = cf:Inverse() * lshoulder.Part0.CFrame * lshoulder.C0
end
	
	game:GetService("RunService").RenderStepped:Connect(function()
		armPosition()
	end)```


I would provide screenshots but there is nothing to screenshot. My arm just flings away when you equip it, and I have no idea why.
Thanks, Have a great day :slight_smile:

Do you get any errors?

Also you are not calling the updateArm function.
And you are missing this line:
viewModel.Head.CFrame = camera.CFrame;

Hey, thanks for the reply

No errors, that line is handled in my main client script.
Everything works, except for the armPosition() .

You only have code for the right arm? What about the left?

im trying to get the right done first, and then ill do the left. Ill try adding the left and see if that adds some sort of stability

I tried it, now both arms fling away

If the rest of the code works, I’d try to first copy and paste from the guide to see if it works then compare your new and old code.

I checked out the uncopylocked version, i cant find any real differences between this one and my one. Not sure what else to try.