How do you make a value-dependent variable scoreboard objective? (Command Blocks, 1.16.5)

How do you make a value-dependent variable scoreboard objective? (Command Blocks, 1.16.5) - Interior of modern office lounge zone with sofa and armchair with table near window next to TV on wall and neon signboard with text do what you love near door

It's a bit difficult to explain in the title - basically, what I'm doing is making a Red vs. Blue team game that's almost completely powered by command blocks for its inner workings. A friend of mine helped me with the start, but he's become burned out and has shown me how a lot of it works so far so that I can continue it on my own.

The gamemode puts people in a small arena separated by a wall cutting off the entire middle, where people fight it out after the walls fall in a certain amount of time. Command blocks power most of it, but there's also an operator that controls a panel above the arena. I could just have the operator press a button to trigger some command blocks to say a team has won, but I want to cut out as much of this manual operation as possible.

The teams win via a kill requirement that varies based on how many teammates there are. Teams are selected evenly, but there can be times when there is an extra member on one of the two teams due to it not being even. This is fine, as the win requirement is that teams must get to 5 kills per person on the team. If there were 7 people on a team, it would require 35 kills to win. If the other team had 6 people, it would require 30 kills.

My problem: I've already worked out the combined number of kills. I don't know how to set a variable based on the number of players on the team, which (once the requirements are met) then triggers a series of command blocks to say a team has won.

It should also be noted that this is being done on a 1.16.5 (latest) Paper server with EssentialsX, WorldGuard, and some other QoL plugins.

TL;DR - Need a command, based on a # of teammates on one of two teams, that determines a playercount-based win requirement of kills.



Best Answer

What you will need to do is compare the scores against one another. Here I store the kill quota in another score:

execute if score RedTeam kills >= RedTeam killQuota run say Red wins!
execute if score BlueTeam kills >= BlueTeam killQuota run say Blue wins!



Pictures about "How do you make a value-dependent variable scoreboard objective? (Command Blocks, 1.16.5)"

How do you make a value-dependent variable scoreboard objective? (Command Blocks, 1.16.5) - Crop faceless informal woman with opened notebook
How do you make a value-dependent variable scoreboard objective? (Command Blocks, 1.16.5) - From above of tool for production of traditional Vietnamese noodles with white dough near plastic container and wicker basket
How do you make a value-dependent variable scoreboard objective? (Command Blocks, 1.16.5) - Content female customer with long curly hair wearing casual outfit sitting at wooden table with netbook in classic interior restaurant while making online order



How do you add a value to a scoreboard in Minecraft?

Scoreboard Command
  • To add an objective: /scoreboard objectives add <objective> <criteria> [displayName]
  • To remove an objective: /scoreboard objectives remove <objective>
  • To list all objectives: /scoreboard objectives list.
  • To set how the objectives are displayed: /scoreboard objectives setdisplay <slot> [objective]





  • Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

    Images: Max Vakhtbovych, Skylar Kang, Quang Nguyen Vinh, Yan Krukov