TransWikia.com

How to give a player an item if their level is of a certain minimum value, and make sure that they only have one of these items at a time?

Arqade Asked by Cory Ackley on January 20, 2021

I would like to accomplish this using a single command in a command block that is set to repeat, and I’d like to avoid using the scoreboard. I’m looking to check whether or not the player’s level is above Lv.15, and if so, give them a tripwire hook named “15EXP Key”. I’d also like to make sure they only have one of these keys at a time, so as to encourage using them before acquiring any more experience. I had tried this, but it didn’t work how I had expected it to:

/execute unless entity @a[nbt={Inventory:[{id:"minecraft:tripwire_hook"}]}] run give @a[level=15..] minecraft:tripwire_hook{Name:"15EXP Key"} 1

Moreover, this command will be used in an area with multiple nearby players, and I’d like it to only apply to players in a certain specified area, but I have no idea how to do that. Also, it should apply to those players individually so that if one player has the required levels and the other does not, the player with the right level should receive the item but the other should not.

One Answer

Check out this command:

/execute as @a[scores={level=15..},nbt=!{Inventory:[{id:"minecraft:tripwire_hook"}]}] run give @s tripwire_hook{display:{Name:""15EXP Key""}}

Notice I've added a Count in the nbt, moved the score condition to the execute command and did some tweaking to your code to code I know would work. However, I have not tested this, but by the looks of it it should definitely work.

Answered by SpiceWeasel on January 20, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP