Reduce scoreboard value instantly by the value of another score
So I have a scoreboard objective of damage resisted, and it instantly increases based on damage i take with the resistance eff active. In short, I need to reduce the value of the player's "h" (health) score by whatever is the player's damage resisted score.
I did this odd thing where I reduced the value of the resisted score by 30 each time and reduced 30 on the health, but I need it to be instant, so if I took 300 damage, the value of my "h" score should drop instantly by 300. Is there a way for this? Able to use commands up to the latest snapshot.
Best Answer
Okay so if I understand correctly, you have a scoreboard objective let's call it damageTaken. Each player's score is set to how much damage they take. If this is the case then you should be able to do
/execute if entity @a[scores={damageTaken=2..}] store success score @s damageTaken run scoreboard players operation @s health -= @s damageTaken
This works as long as the damageTaken score is greater than 1 (just fix that by making the minimum damage 2 or make it multiples of 10 or something). It's just one command, it works for multiplayer, and it resets itself
-cheers
Pictures about "Reduce scoreboard value instantly by the value of another score"



Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Monstera, Alesia Kozik, Brett Sayles, Karolina Grabowska
