1

Is there a way i can check for a specific player standing on a block or is nearby and command block, and have it run another command like /setblock so it can execute other command blocks? So like if a player presses a button, it checks if the player has a certain nametag, and if not it doesn't open any door. But if the player does have a certain name tag then it opens the doors.

0

Use target selectors, and use /execute to make it happen.

/execute if entity @a[x=10,y=20,z=30,distance=..10] run setblock 1 2 3 redstone_block

This will detect any players within 10 blocks of XYZ (10, 20, 30), and if any are found, it sets a redstone block at a certain position, whether to run more commands, or to open an iron door.

And to detect the name, use the name argument.

/execute if entity @a[name=ExpertCoder14] run ...

Combine these all together and you get:

/execute if entity @a[x=10,y=20,z=30,distance=0..5,name=ExpertCoder14] run setblock 1 2 3 redstone_block

Learn more about these commands and mechanics on the Minecraft Wiki:

| 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.