I'm having trouble getting my player to lift objects in 2D

I’m trying to lift an object when the up arrow is pressed by using the following code

this.transform.parent = player.transform

This appears to work until I add rigidbody 2D to an object. Once it has the rigidbody however, the object detaches as soon as the player jumps.

Another issue is the objects slide away as soon as the player collides with it.

If you have any ideas as to what may be causing this, I’d appreciate the help.

Have you tried this? Unity - Manual: Spring Joint 2D