Testing for specific player a with command block

I was trying to make a door that only opened when it was me walking across the tripwire. The first block has the code:

testfor @p[1303,56,518,2,n=PlayerName]

It is impulse, unconditional and needs redstone.

The others use (repeated for all of the blocks):

setblock 1304 56 515 air

They are chain, unconditional and always active.

However the condition for the name doesn't have any effect. I tested it on 2 accounts and the door opened on both. Am I using the syntax wrong or is there something else I'm missing?


**Edit - The problem has been confirmed as the pick block key saving all states correctly other than the conditional.**

it used to save the conditional state since it was originally saved as NBT. However, it was changed later on during the 1.9 snapshots to be a blockstate rather than NBT. The reason behind that is because changing the conditional setting via NBT would not prompt the client to render the block anew, making it appear as a regular command block instead of conditional. Changing a blockstate would allow the client to re-render it. Pick-blocking only saves NBT, so that blockstate is lost. – Skylinerw


There is no n parameter. The correct parameter you're looking for is name. The wiki has a list of all valid parameters here.

testfor @p[1303,56,518,2,name=JAMES_the_camel]

For 1.11-1.12, which removes shorthand coordinates:

testfor @p[x=1303,y=56,z=518,r=2,name=JAMES_the_camel]

And for 1.13+, which overhauled the command system (where /testfor has essentially been merged into /execute):

execute if entity @p[x=1303,y=56,z=518,distance=..2,name=JAMES_the_camel]

As well, because your chain is unconditional, it's going to activate no matter what and open the door. If you set it to conditional, it will only run its command if the command block physically behind it was successful. You will want to set your chain block to conditional or otherwise activate another set of command blocks based on the success of /testfor.