0

I am trying to do command blocks for a map this kid in my class but have got stuck on a particular part. So what I am trying to do is every 20 game ticks effect them with instant damage then reset the scoreboard counter but only while they are within a 2 block radius of a Armour stand named damage-radius (that is also the scoreboard name) The problem I'm having is when 1 person is within that radius it adds to the scoreboard of all players thank you in advance here is what I have done already these are running in chain command blocks that are always active with command 2 and 4 being conditional also im pretty sure the command is in the 2nd command block

execute @a ~ ~ ~ /testfor @e[name=damage-radius,r=5]

/scoreboard players add @a damage-radius 1

/effect @a[score_damage-radius=20,score_damage-radius_min=20] minecraft:instant_damage 1 1

/scoreboard players set @a[score_damage-radius_min=20] damage-radius 0

2

I am going to explain what your commands are actually doing.

execute @a ~ ~ ~ /testfor @e[name=damage-radius,r=5]

This means execute the command testfor @e[name=damage-radius,r=5] from the location of all players. This will result positive if there is an armor stand within 5 block radius of the player and run the next command. It does nothing to target the player. It only returns that there is an armor stand near a player.

/scoreboard players add @a damage-radius 1

This means add 1 to the damage-radius objective for all players. This does not target any specific player. This is your problem.


A better way to do it. First, skip the testfor. Second, run the command directly by targeting the player that is near the armor stand (Backwards of your method of targeting an armor stand that is near a player)

execute @e[name=damage-radius] ~ ~ ~ scoreboard players add @a[r=5] damage-radius 1

This means execute the command scoreboard players add @a[r=5] damage-radius 1 at the location of an entity named "damage-radius."

This will add 1 to the damage-radius objective of only the player that is near the armor stand.

Your other two commands will work as they are.

0

You should instead do

execute @e[name=damage-radius] ~ ~ ~ scoreboard players add @a[r=5] damage=radius 1
effect @a[score_damage-radius=20,score_damage-radius_min=20] minecraft:instant_damage 1 1
scoreboard players set @a[score_damage-radius_min=20] damage-radius 0

Even better, just use an area effect cloud:

summon area_effect_cloud ~ ~ ~ {Particle:take,ReapplicationDelay:20,Radius:5f,Duration:2147483647,Effects:[{Id:7,Amplifier:0,Duration:20}]}
  • than you for the help but this is for a lot of Armour stands at once so the area affect is not better suited and other way is more suited for it – GAMERINE Aug 25 '17 at 2:31

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.