How to clear a specific number of a specific item from a players inventory?

I am making a bed wars map and I wanna make it so when the player clicks a button, it give them 16 wool and takes away 4 iron. I have found out how to take only a specific item but how do I take a specific amount? For example, how I have it set up now, no matter how much iron the player has, it takes it all and only gives 16 wool. I want it to only take 16 at a time.


Solution 1:

Basically, the command is similar to /give; after you specify the item you need to specify the variant and amount. In this case, it would be

/clear @p minecraft:iron_ingot 0 4

0 is the variant, which in iron ingots there are none, but in things like colored blocks may need to be changed. The 4 is the amount.