Using scoreboards as varibles
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?
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>