object move back and forth on key smoothly

am trying to add a sprinting effect where when i hold shift your swords will go back smoothly then when i release it goes back, i tried to make it but the swords just stay far away from the player and move weirdly

heres the code

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class effects : MonoBehaviour
{
    [SerializeField] float lerptime = 20;


    // Start is called before the first frame update
    void Start()
    {
       
    }

    // Update is called once per frame
    void Update()
    {

        if (Input.GetKey("left shift"))
        {
            sprintingaction();
        }
        else
            stopsprintingaction();
           
    }

    public void sprintingaction()
    {

        transform.position = Vector3.Lerp(transform.position, new Vector3(-0.1f, -4.73f, 11.977f), lerptime * Time.deltaTime);

    }
    public void stopsprintingaction()
    {
        transform.position = Vector3.Lerp(transform.position, new Vector3(-0.1f, -4.73f, 9.977f), lerptime * Time.deltaTime);
    }
}

Take a look at the docs: Unity - Scripting API: Vector3.Lerp

i just fixed it! if anyone else is having a problem similar to this, replace transform.position with transform.localPosition