Minecraft – execute @e with scoreboard does not work

minecraft-commandsminecraft-java-edition

I have a squid with a custom name of "Create_Pig_Alter", and whenever it is "standing" on stone, I want to set a scoreboard objective for the squid. I've tried the following command, but it isn't working:

/execute @e[name=Create_Pig_Alter] ~ ~ ~ detect ~ ~-1 ~ stone /scoreboard players set @e PigAlterProgress 1

What am I doing wrong?

Best Answer

"detect" syntax for /execute:

/execute <target> X Y Z detect X Y Z <block> <Damage> <command>

You are missing the Damage value of the block. You can set the value to -1 to signify any value. Fixed command using a value of 0 for regular smooth stone:

/execute @e[name=Create_Pig_Alter] ~ ~ ~ detect ~ ~-1 ~ stone 0 /scoreboard players set @e PigAlterProgress 1