-4

I am making a dropper mini game on my Minecraft server and I am using a button to give a player the diamond. I need a command block that sees if they have a diamond already so they don't get two diamonds.

1

Assume they don't have diamond at first by adding a tag by default:

/scoreboard players tag @a add d

If they do have a diamond, remove the tag:

/scoreboard players tag @a remove d {Inventory:[{id:minecraft:diamond}]}

Give players that have the "d" tag a diamond:

/give @a[tag=d] diamond
2

This can be done in just one command in Minecraft 1.13

/give @a[nbt=!{Inventory:[{id:"minecraft:diamond"}]}] diamond
1

You can run a clear command and then give them the diamond

/clear @p minecraft:diamond 1 0

Then...
/give @p minecraft:diamond 1 0 {display:{Name:"Optional Name"}}

Not the answer you're looking for? Browse other questions tagged or ask your own question.