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?

1
  • 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). Feb 11, 2019 at 17:55

1 Answer 1

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.wiki/w/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.wiki/w/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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .