0

I'm working on a system to detect right clicks using a villager and than trigger several commands. I'm using an always active repeating commandblock to start a chain of commandblocks which run the commands I need them to run. I've setup a scoreboard objective called torchLever and set it to:

minecraft.custom.talked_to_villager

so it increases everytime I talk to a villager.

I'm now trying to see if a player has the value of the scoreboard set to 1 with this command

/execute as @p if score @s torchLever matches 1.. run say hi

however this does not seem to work. I've tested a few different commands like the one in this article but that doesn't work either.

How can I see if there is a player with the torchLever score set to 1 and than start executing a bunch of commands?

  • In future questions, please specify what happens. If I hadn't read the answer, I would have assumed that "it doesn't work" means that it always evaluates to true (which happens if you forget to reset the scoreboard after use). – Fabian Röling Feb 11 at 17:55
1

First off, your objective is a synax error. The correct way is:

/scoreboard objectives add torchLever minecraft.custom:minecraft.talked_to_villager

As can be seen on the minecraft wiki (https://minecraft.gamepedia.com/Scoreboard#Objectives).

Secondly, your execute command is needlessly complicated. Though it may seem pretty simple at first glance, there is an even simpler and more efficient way to execute players with a score, or many scores:

execute as @a[scores={torchLever=1..}] run say hi

As can be seen on the minecraft wiki (https://minecraft.gamepedia.com/Commands#Usage, scroll down to "target selector arguments).

Since you didn't specify what version of minecraft you're using, I assumed it was 1.13 Java Edition.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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