Check if specific player nearby in Minecraft 1.15.2

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:

  • Target selectors
  • The /execute Command