Minecraft Commands – How to Play a Message if a Command Block Isn’t Activated

minecraft-commandsminecraft-java-edition

I am making a class system and I want a message to be played when the class fails to be unlocked (a command block wasn't activated after a specific input). After the sequence plays, I want to use a /say command to tell the player that the class wasn't unlocked.

Best Answer

You can check the SuccessCount integer tag value of a command block by using the /testforblock command. If the value is 0, the command block either did not activate or did not run its command successfully. Replace the coordinates with the command block you want to check:

/testforblock X Y Z minecraft:command_block -1 {SuccessCount:0}

The above command block would output if the other command block did not, and you can use that signal to activate your desired commands to notify the player.