2

I am making a map and I need to kill any player that steps on an iron block, but the commands aren't working. Here are the commands:

  • Prequisites:

    /scoreboard objectives add IRONDEATH dummy
    /scoreboard objectives setdisplay sidebar IRONDEATH
    
  • Repeat always active command blocks:

    /scoreboard players set @a IRONDEATH 0
    
  • Chain always active command blocks:

    /execute @a ~ ~ ~ detect ~ ~1 ~ iron_block 0 /scoreboard players set @a[c=1,r=1] IRONDEATH 1
    
    /execute @a[score_IRONDEATH_min=1] ~ ~ ~ /kill @a[score_IRONDEATH_min=1]
    

2 Answers 2

2

The error is with your detect coordinates. ~ ~1 ~ means 1 block above the player's position, rather than 1 block below which would be ~ ~-1 ~.

If you don't need to do anything else with the IRONDEATH score, you could also simplify this down to:

execute @a ~ ~ ~ detect ~ ~-1 ~ iron_block 0 /kill @a[c=1]
1
  • thanks for the halp it was the coordinates that i had wrong i set it to ~ ~-1 ~ and now it wors
    – Alex
    Jan 5, 2017 at 23:19
-1

You can use this command:

/execute @a ~ ~ ~ detect ~ ~-1 ~ iron_block 0 kill @p[c=1]
3
  • this work but it kills all players if 1 steps on an iron block i need this ti kill only the player that will step on the iron block
    – Alex
    Jan 5, 2017 at 23:05
  • 1
    @p only targets living players. After it kills the first player who actually stepped on the iron block, the command will activate again (as they're still on the iron block, just dead) and target the next closest player to kill, then the next closest player, and so on. You should use @a[c=1] to prevent this (though it doesn't really add anything to the earlier answer).
    – SirBenet
    Jan 5, 2017 at 23:27
  • i changed the command to teleport the player but i will try this too
    – Alex
    Jan 6, 2017 at 9:52

You must log in to answer this question.

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