0

I have a command that checks if a player's score is 0 and the block they’re standing on is emerald.
I wrote:

/execute as @a if block ~ ~-1 ~ emerald_block if score @s floor matches 0 run scoreboard players @s floor 1 

but this looks at all players simultaneously for emerald and 0 score, rather than one at a time. I’m out of ideas to fix it.
Can someone help me?

1
  • Try adding at @s after as @a to run the command relative to each player.
    – LostXOR
    Jul 30, 2023 at 23:04

1 Answer 1

2

The problem is that as @a does not, by itself, change where the command is being executed, only who it is being executed by. So the if block ~ ~-1 ~ emerald_block is checking the block under the command block, not the block under the player.

Add at @s after the as @a. This will move command execution to the current entity's location before it checks the block.

Also, scoreboard players @s floor 1 is not a valid command. You probably meant scoreboard players set @s floor 1 (note the set).

The full fixed command would look something like

/execute as @a at @s if block ~ ~-1 ~ emerald_block if score @s floor matches 0 run scoreboard players set @s floor 1 

You must log in to answer this question.

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