Making a destructible rock/tree that gives resources?

Not sure if I’m in the right section here so sorry if I I’m not.

I want to make a tree/rock that lets you hit it and slowly gets destroyed and you get resources after each hit. (i.e. when you hit a tree you get wood after hitting it.)

Any feedback is greatly appreciated. Not sure how I would go about doing this.

You would have to somehow trace the fact you hit the tree. Then have the tree carry a hp value that translated into wood/hp damaged. Then have that amount of wood added to the player inventory. Aside from getting too specific which would take a huge amount of explaining that is the basic.