I know that there is no direct way to create a variable in Minecraft but is there any way to manipulate scoreboard objectives into creating one?

Basically, I need to create a variable that will store a players X Y Z when they reach less than 10 health. The name of the "Health" objective is "down".

I'm not sure how to make this question less like a demand. I'm not sure where to start on this but the main thing that I am "Capable" of is looking online for other questions. The only thing that has come up are people asking for this to be added, but someone in a forum mentioned scoreboard objectives being able to do the trick.


So I don't beleive I was clear enough: I need this to store the players location data live. As in a repeating command block test's for a player with less than ten health and then stores the players current location which I can then use later to teleport the player to the saved coordinates. E.g

/testfor @a[score_down=10] {Coordinated:[{X(var X) = 1,Y(var Y) = 2,Z(var Z) = 3}]}

Basicall y ^ that works like Coordinated < Position Tag, X < X position tag, var < declared that the output will be the variable.


But I hope you catch my drift by the way I explain it.


I realised that there was an alternative way to do what I needed to do and this did not involve creating a variable. The reason I wanted to know the player's location live was so I could freeze them on the spot. Instead, I used this:

/execute @a[score_down=10] ~ ~ ~ /summon ArmorStand ~ ~ ~ {Invisible:1b,Invulnerable:1b,NoBasePlate:1b,NoGravity:1b,Small:1b}

/tp @a[score_down=10] @e[type=ArmorStand]

You can, of course, give the ArmorStand a custom name to reduce glitchiness but I did not need it.


today I was searching how to make a variables and I found, that closest thing to variables is a /scoreboard objectives add score dummy "score"

edit: score is a name of the variable

  • 1
    Could you expand on this with a short example of how it' used? Thanks! – Wipqozn Sep 21 '19 at 12:02
  • /scoreboard objectives add score dummy "score" /gamerule commandBlockOutput false and place 1 minecraft:repeating_command_block and after that 2 minecraft:chain_command_block and put this command in a first command block(that repeating one): /execute at kudy_zero if block ~ ~-1 ~ grass_block run scoreboard players set kudy_zero score 1 second block: /execute at kudy_zero if score kudy_zero score matches 1 run setblock ~ ~-1 ~ minecraft:quartz_block replace third /execute at kudy_zero run scoreboard players reset kudy_zero score – kudy Sep 21 '19 at 13:24
  • My comment was too long so I shortened it only to the commands, first command will make a variable named score, second command will provent you from getting spammed in a chat by command blocks, and last three commands that you will put in a powered command blocks will do that every time you step on a grass block it will give you score 1 and if you have a score it will replace it with a quartz block. – kudy Sep 21 '19 at 13:29
  • And my minecraft nick is a kudy_zero so if you copy those commands and paste them in your command blocks it won't work, beacuse it is on my name, you must delete kudy_zero and type your name. – kudy Sep 21 '19 at 13:31
  • 2
    Thanks Kudy! That example is really hard to read in comments. Would you mind editing that information into your answer? I'd do it myself, but I don't have a lot of experience with Minecraft commands, so I don't think I'd be able to get it quite right. – Wipqozn Sep 21 '19 at 13:50
/scoreboard objectives add score dummy "score"  

/gamerule commandBlockOutput false 

/execute at [your name] if block ~ ~-1 ~ grass_block run scoreboard players set [your name] score 1

/execute at [your name] if score [your name] score matches 1 run setblock ~ ~-1 ~ minecraft:quartz_block replace  

/execute at [your name] run scoreboard players reset [your name] score
  • Care to explain how the syntax works? – aytimothy Sep 22 '19 at 8:28
  • I explained it in my previous answer to Wipqozn. It will basically put a quartzblock under you when you stand on a grassblock. – kudy Sep 22 '19 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.