Why is =! not working in testfor command?

I am building a proximity alarm on a server that should go off when someone other than me approaches my house. However, the output of my command block keeps turning up as something along the lines of “The entity value is not a valid one”

My command is:

  • How can I make a random number generator with command blocks in Minecraft?
  • Chances of encountering a charged creeper?
  • How do I get armor to add a potion effect?
  • How hungry will I get from a boat trip?
  • How do I get minecraft heads from a specific player skin
  • Minecraft on PC and Wii U
  • /testfor @p[name=!Myname]

  • How do I install Forge 1.6.4?
  • How do I testfor/scoreboard a Player in a MinecartRideable (1.9)?
  • Can monsters naturally spawn on blocks covered by pressure plate?
  • minecraft command block testfor certain player
  • Why does Minecraft get stuck when javaw.exe reaches 757.356kb of memory use?
  • Why remove redstone dust from my command block contraptions?
  • 2 Solutions collect form web for “Why is =! not working in testfor command?”

    The name is case sensitive, so make sure you put it right.
    Also you need to enter a radius (r=radiusInBlocks) or it will check the whole world.

    Other than that it will output an error, when the detection doesn’t return a result (e.g. it’s just you hanging around there). Don’t worry about that.

    /testfor @p[name=!dly,r=3] with just me in that radius will return an error, because there is no player around, who’s not me.
    /testfor @p[name=dly,r=3] will return a positive.

    You could as well add full coordinates, if you have the command block somewhere else.
    Just add x=xValue,y=yValue,z=zValue to your command.

    This is an easy solution to your command.
    If you use this command:

    /execute @p[name=!YourName,r=10] ~ ~ ~ tell <YourName> Warning: @p is at your house!

    and put it inside a command block on a slow Redstone clock, you will get warned each time somebody is around/in your house. I tested this on my server, and it works fine, especially when I replaced the single command block with more Command blocks with these commands:

    /execute @p[name=!YourName,r=5] ~ ~ ~ tell @a[name=YourName] Warning: @p is 5 or less blocks from your house!  
    /execute @p[name=!YourName,r=10] ~ ~ ~ tell @a[name=YourName] Warning: @p is 10 or less blocks from your house!  
    /execute @p[name=!YourName,r=20] ~ ~ ~ tell @a[name=YourName] Warning: @p is 20 or less blocks from your house!
    We love Playing Games, especially Video Games.