How to kill someone standing on a certain block [closed]

So I am building a minecraft parkour. In a certain level, people may not walk on the red wool. When they walk on it, they die.

Can someone help with the code on my command block ?

I have this right now :

/execute @a [XYZ] ~ ~ ~ detect ~ ~-1 ~ minecraft:wool 14 kill @p

/execute @a[r=radius] ~ ~ ~ detect ~ ~-1 ~ minecraft:wool 14 kill @a[c=1]

This should work..

  • Put the command block in the center of that area and use a radius covering it, so people don't die where they shouldn't.

  • Use @a[c=1] instead of @p, because someone else walking by could die when there's still someone who died and hasn't respawned.

  • As proposed in the comments the selector @s can as well be used instead of @a[c=1] (assuming you're on 1.12). This will target the entity that is executing the command.