horizontal recoil reset with slerp

Hello! I am currently trying to implement horizontal-only recoil to my weapon. For that, I rotate the weapon after shooting either to the left or to the right. After I am done shooting, I want to rotate back with using the slerp function. However, I cant figure out how something like that would work. I tried saving the position in a quaternion, but that created another problem, where if you would shoot and move your mouse horizontally, it would just revert your rotation to the old rotation, sometimes even rotating the character by 180°.
My code can be found below. I don’t expect you to provide code, just instructions are highly appreciated too!

void Start()
    {
        originalPosition = transform.rotation;
    }
    void Update() {
        while (slerpYes && transform.rotation != originalPosition)
        {
            transform.rotation = Quaternion.Slerp(transform.rotation, originalPosition, 6f * Time.deltaTime);
            Debug.Log("Test");
        }
        StartCoroutine(Recoil());
        
    }

    private IEnumerator Recoil()
    {
        slerpYes = false;
        int resetTimer;
        if(Input.GetMouseButtonDown(0))
        {
                resetTimer = Random.Range(0, 2);
                if (resetTimer == 0)
                {
                    transform.Rotate(0, 1.75f, 0);
                }
                else if (resetTimer == 1)
                {
                    transform.Rotate(0, -1.75f, 0);
                }
            yield return new WaitForSeconds(0.15f);
            slerpYes = true;
            Debug.Log("Test2");
        }
    }

I’m assuming this is a first-person shooter you’re describing, so this answer works with that in mind.

The most straightforward approach would probably be to add an empty GameObject controller as a parent to your camera (again, assuming first-person shooter), then use its Transform for modifiers related to recoil. Whenever it’s inactive (you’re not firing), its localRotation would be none, or Quaternion.identity.

When you fire, nudge the localRotation of that empty GameObject to be off-center, then ease it back toward the original rotation. Then, you won’t need to worry about any player-made changes to rotation during that time.