Positional recoil not working properly

I have a gun which it has 2 scripts: a weapon sway and a recoil script (attached below). If i would’ve set the localPosition to currentPosition in the recoil script, the weapon sway doesn’t work properly

private Vector3 currentPosition;
    private Vector3 targetPosition;
    private Vector3 initialPosition;
   
    public float kickBackZ;

    public float snappiness;
    public float returnSpeed;
   
    void Start()
    {
        initialPosition = transform.localPosition;
    }

    void Update()
    {
        targetPosition = Vector3.Lerp(targetPosition, Vector3.zero, returnSpeed * Time.deltaTime);
        currentPosition = Vector3.Slerp(currentPosition, targetPosition, snappiness * Time.fixedDeltaTime);
        transform.localPosition = transform.localPosition + currentPosition;
    }

    public void RecoilFire()
    {
        targetPosition += new Vector3(0, 0, kickBackZ);
    }
public Movement playerMovement;
   
    [Header("Position")]
    public float amount = 0.02f;
    public float maxAmount = 0.06f;
    public float smoothAmount = 6f;

    [Header("Rotation")]
    public float rotationAmount = 4f;
    public float maxRotationAmount = 5f;
    public float smoothRotation = 12f;

    [Space]
    public bool rotationX = true;
    public bool rotationY = true;
    public bool rotationZ = true;
   
    private Vector3 initialPosition;
    private Quaternion initialRotation;

    private float inputX;
    private float inputY;
   
    void Start()
    {
        initialPosition = transform.localPosition;
        initialRotation = transform.localRotation;
    }

    void Update()
    {
        CalculateSway();
       
        MoveSway();
        TiltSway();
    }

    void CalculateSway()
    {
        inputX = -Input.GetAxis("Mouse X");
        inputY = -Input.GetAxis("Mouse Y");
    }

    void MoveSway()
    {
        float moveX = Mathf.Clamp(inputX * amount, -maxAmount, maxAmount);
        float moveY = Mathf.Clamp(inputY * amount, -maxAmount, maxAmount);

        Vector3 finalPosition = new Vector3(moveX, moveY, 0);

        transform.localPosition = Vector3.Lerp(transform.localPosition, finalPosition + initialPosition, smoothAmount * Time.deltaTime);
    }

    void TiltSway()
    {
        float tiltY = Mathf.Clamp(inputX * rotationAmount, -maxRotationAmount, maxRotationAmount);
        float tiltX = Mathf.Clamp(inputY * rotationAmount, -maxRotationAmount, maxRotationAmount);

        Quaternion finalRotation = Quaternion.Euler(new Vector3(
            rotationX ? -tiltX : 0f,
            rotationY ? -tiltY : 0f,
            rotationZ ? -tiltY : 0f
        ));

        if (playerMovement.isDashing)
        {
            transform.localRotation = Quaternion.Slerp(transform.localRotation, Quaternion.Euler(transform.localRotation.x, transform.localRotation.y, -Input.GetAxisRaw("Horizontal") * maxRotationAmount), smoothRotation * Time.deltaTime);
        }

        else
        {
            transform.localRotation = Quaternion.Slerp(transform.localRotation, finalRotation * initialRotation, smoothRotation * Time.deltaTime);
        }
    }

Use two transforms parented to each other, one to recoil, probably below the one that sways:

RecoilingTransform
GunOrCameraOrWhateverIsRecoiling```

What for?

Um, to fix your reported problem? As you said:

Otherwise, if you want to mix it all yourself, then do so! Those scripts will need to “play well together,” as in one gives output to the other, which is further modified before application.