Help picking up and moving objects

I’m having a little trouble. I want to be able to have the player walk up to something, press a button, and if an object is in range, pick it up and be able to move it. And then be able to drop it later. Sounds simple, but I just can’t seem to get it. I’m extremely new to Unity and java so I would appreciate help.
At first I tried using raycasts to determine if I was in range and what the object was. If the object had the right tag, it would become a child to the player character so I could move it. But I quickly realized I had no idea how to “un-parent” the player so the object could be dropped. I don’t know if I was headed in the right direction or not. So if someone could possibly tell me how to un-parent the player or even tell me how to do it in a completely different way, I would much appreciate it =)

It sounds like you’re on the right track. As for un-parenting, I think it can be done as follows:

childObjectToUnparent.transform.parent = null;

i got another question.
i want to move an object e.g like a cube , randomly into a limited space like
position.x = Random.Range(-4,4)
position.y = Random.Range(-4,4)
but as we know position does not translate the object its just snap to the position

Might be what your looking for in terms of smooth movement.