How can I make a wall that you can break with a weapon?

Hi I was creating a game and I wanted to know how you can make wall breakable and then get something from it

Create a destructible mesh:

To get something from it, you probably can just spawn an object at the location of the rubble.

In that case, use particles. Spawn particle emitter on hit. Keep accumulating damage dealt in a variable. Once you’ve reached a threshold, destroy the object you were hitting and spawn loot object.

If you do not need particles / debris fly out, adjust the texture of the hit object, indicating how damaged it is.

edit: perhaps I misunderstood you and you’re actually after the very basics of damage dealing. Have a look at this, it’s short and conclusive:

I am trying to make when you break the wall it is clean and rubble doesn’t fly everywhere like in Fortntie or Minecraft