Why is my align rotation super shaky?

Hey there!

I’m trying to make a custom shiftlock, but it seems to be super shaky.

This is my code:

local _, y, _ = cam.CFrame:ToObjectSpace(hrp.CFrame):ToEulerAnglesXYZ()

hrp.CFrame = hrp.CFrame*CFrame.Angles(0,-y,0)
align.CFrame = CFrame.Angles(0,-y,0)

align is an AlignOrientation. I need this to keep the character upright, but it’s also what causing the shaking. How would I fix this, or is there a better way to keep the player up?