1

I have a problem with my redstone/command blocks circuit. My redstone circuit:

redstone circuit

In command block 1, the command in that block is:

/testfor @a [score_health=19,score_health_min=1]

(this sends a redstone signal when their is a player with less than 10 hearts).

In command block 2 the command is:

/replaceitem entity @p slot.armor.head diamond_helmet 1 0

(when activated it places a diamond helmet on your head)
The rest of the commands are for other armor pieces.

When someone has less than 10 hearts, it activates the other commands but gives the nearest player the armor. How do I make it so that the "armor wear" commands only effect the player who has less than 10 hearts?

2

/replaceitem has a target selector. Just use /replaceitem instead of /testfor.

/replaceitem entity @a[score_health=19,score_health_min=1] slot.armor.head minecraft:diamond_helmet 1 0

Relying on physical redstone logic when dealing with multi-target situations will make it difficult or impossible to support it. For example, you mechanism appears to turn on and stay on as long as a player has that health, which means any future players that meet those requirements will not be affected because the mechanism is locked due to the first detection. Removing physical logic and using /replaceitem on the clock will allow it to support multiplayer.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.