In my minecraft map, I have a scoreboard, mainvars, that I made by running /scoreboard objectives add mainvars dummy, that has 1 player called var I made by running /scoreboard add players var mainvars 5.

I tried to test if var = 5 with /testfor var[score_mainvars=5], but it doesn't work.

EDIT:but /testfor @p[score_mainvars=5] works? I'm confused. Any help?

2 Answers 2


You cannot use a player's name in place of an @ selector. If you want to test for someone with a certain name, use the name argument:

/testfor @a[name=var,score_mainvars=5]

Keep in mind that @a selects player entities that exist somewhere in the world, not every single possible username. e.i. this will only work if there is actually a player called "var" currently on the world.

If you're wanting to test for a scoreboard objective value, rather than an online player, then you should use the /scoreboard players test command. The syntax is:

/scoreboard players test <player> <objective> <min> <max>

Scoreboard assigns the value of a variable to each and every player. Take for eg- There is a variable called money. Now, it has no central value corresponding to the game, but it has a unique value for each and every player. And hence what you wrote later was correct.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .