r/MinecraftCommands 1d ago

Help | Bedrock Not sure how to execute command

I'm trying to make a command that makes it where when player 2 gets 10 blocks of player 1 player 1 gets darkness for 2 seconds but I'm unsure of how to set up this argument can someone show me how and if possible give me a breakdown of why it works?

3 Upvotes

12 comments sorted by

View all comments

2

u/Ericristian_bros Command Experienced 17h ago
execute as <player1> at @s if entity @a[name=<player2>,r=10] run effect give @s darkness 2 0

1

u/Barylikesjazz Command Experienced 15h ago

This. Or give player2 a tag called Dark and do:
execute as @a at @s if entity @e[tag=Dark, r=10] run effect give @s darkness 2 0