Minecraft – How to do /scoreboard players test functions in 1.14

minecraft-commandsminecraft-java-edition

I have just recently started learning how to use command blocks and I have began learning scoreboards. I have a scoreboard setup which tracks my mob kills. I am trying to make it so that when the value reaches 10, the command block says hi. The command I have in right now is execute if entity @p[scores={totalKills=10..}] at @p run say hi.

When my score is already 10, it triggers the say hi, but when I set it back to 9 and kill a mob to move it up to 10, it doesn't trigger the say hi. It will also pop up if I switch the command block between Needs Redstone and Always Active or if I have it on Needs Redstone and turn it on and off.

What exactly am I doing wrong?

Best Answer

It sounds like you are using an impulse command block.

In your case it seems like you want a repeating command block, or you can build a redstone clock that activates your command block repeatedly.

You may want to build something that looks like this, to prevent the player from saying "hi" repeatedly:

enter image description here

You would have this command in the repeating command block:

/execute if entity @p[scores={totalKills=10..}]

And this command in the impulse command block:

/execute as @p[scores={totalKills=10..}] run say hi

An impulse command block activates ONCE whenever you give it a redstone impulse, or the moment you set it to "always active"

A repeating command block is blue, it activates repeatedly, as long as it has a redstone signal going in to it, or as long as it is set to "always active"

A chain command block is green, it activates whenever a different command block that points at it (there should be arrows on the command blocks) and is touching it activates and there is redstone going into it, unless it is set to "always active", in that case it does not require redstone.