My pickup script only moves the object with my mouse

I just followed a tutorial on this physics based pick up script, but for some reason the item im picking up doesnt move with my character, only with my mouse movements. for example if i move side to side and not move my mouse, the item will just stay where its at. and the only time it moves is with my camera movement.

using JetBrains.Annotations;
using UnityEngine;

public class PickupObject : MonoBehaviour
{
    public float pickUpForce = 150f;
    public float pickUpRange = 5f;
    public LayerMask isPickable;

    private GameObject heldObj;
    private Rigidbody heldObjRB;
    public Transform holdArea;

    public Transform player;

    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {
        
    }

    // Update is called once per frame
    private void Update()
    {
        if(Input.GetMouseButtonDown(0))
        {
            if(heldObj == null)
            {
                RaycastHit hit;
                if(Physics.Raycast(transform.position,transform.forward, out hit, pickUpRange))
                {
                    Pickup(hit.transform.gameObject);
                }
            }
        
            else
            {
                Drop();
            }
            if(heldObj != null)
            {
                MoveObject();
            }
        }
        
    }
    void Pickup(GameObject pickObj)
    {
        if(pickObj.GetComponent<Rigidbody>())
        {
            heldObjRB = pickObj.GetComponent<Rigidbody>();
            heldObjRB.useGravity = false;
            heldObjRB.linearDamping = 5;
            heldObjRB.constraints = RigidbodyConstraints.FreezeRotation;

            heldObjRB.transform.parent = holdArea;
            heldObj = pickObj;
        }
    }
    void MoveObject()
    {
        if(Vector3.Distance(heldObj.transform.position, holdArea.position) > 0.1f)
        {
            Vector3 moveDirection = holdArea.position - heldObj.transform.position;
            heldObjRB.AddForce(moveDirection * pickUpForce);
        }
        
    }
    void Drop()
    {
        heldObjRB.useGravity = true;
        heldObjRB.linearDamping = 1;
        heldObjRB.constraints = RigidbodyConstraints.None;

        heldObjRB.transform.parent = null;
        heldObj = null;
        
    }
}

Sounds like you wrote a bug… and that means… time to start debugging!

I would start by finding the part you expect to do what isn’t happening, and then see if it is even executing.

By debugging you can find out exactly what your program is doing so you can fix it.

Use the above techniques to get the information you need in order to reason about what the problem is.

You can also use Debug.Log(...); statements to find out if any of your code is even running. Don’t assume it is.

Once you understand what the problem is, you may begin to reason about a solution to the problem.

Remember with Unity the code is only a tiny fraction of the problem space. Everything asset- and scene- wise must also be set up correctly to match the associated code and its assumptions.

Another way is to simply check over your work by going carefully through the tutorial again.

Two steps to tutorials and / or example code:

  1. do them perfectly, to the letter (zero typos, including punctuation and capitalization)
  2. stop and understand each step to understand what is going on.

If you go past anything that you don’t understand, then you’re just mimicking what you saw without actually learning, essentially wasting your own time. It’s only two steps. Don’t skip either step.

Ill try this, thank you!