Bedrock Wiki
  • Discord
  • Contribute
  • bedrock.dev
  • MS Learn
Beginner's Guide
  • Guide
    • 1. Introduction
      guide
    • 2. Add-Ons Explained
    • 3. Software & Preparation
    • 4. Project Setup
    • 5. Create a Custom Item
    • 6. Create a Custom Entity
    • 7. Blockbench: Modeling, Texturing & Animating
    • 8. Adding a Loot Table, Spawn Rule & Crafting Recipe
  • Extra
    • a. Understanding JSON
    • b. Download Example Packs
    • c. Troubleshooting
      help
    • d. Advanced Manifest
    • e. Format Versions
    • f. Project Setup Android
Animation Controllers
  • Intro to Animation Controllers
    guide
  • Entity Commands
  • AFK Detector
  • Death Commands
  • Molang into Scoreboard
  • Respawn Commands
Blocks
  • General
    • Intro to Blocks
      guide
    • Block Components
    • Block Tags
    • Block States
    • Block Traits
    • Block Permutations
    • Block Events
      Scripts
    • Block Event Migration
      help
    • Blocks as Items
    • Troubleshooting Blocks
      help
  • Visuals
    • Block Culling
    • Block Models
      guide
    • Block Texture Animation
    • Block Texture Variation
    • Block Tinting
  • Tutorials
    • Applying Constant Effects
      Scripts
    • Avoiding State Limit
    • Fake Blocks
    • Ore Loot Tables
      Scripts
    • Precise Interaction
      Scripts
    • Precise Rotation
      Scripts
    • Rotatable Blocks
  • Vanilla Re-Creations
    • Custom Crops
      Scripts
    • Custom Glass
    • Custom Glazed Terracotta
    • Custom Trapdoors
      Scripts
  • Documentation
    • Block Format History
    • Block Shapes
    • Block Sounds
    • Vanilla Block Models
Commands
  • General
    • Intro to Command Blocks
    • Functions
    • Block States
    • Coordinate System
    • NBT Commands
    • Scoreboard Operations
    • Understanding Selectors
  • Commands
    • Damage
    • Execute
    • Playanimation
    • Playsound
  • On Event Systems
    • On Player First Join
    • On Player Join
    • On Player Leave
    • On Player Death
    • On Player Respawn
    • On First World Load
  • Scoreboard Systems
    • Entity Counter
    • Scoreboard Timers
    • Comparing And Retrieving Scores
  • Techniques
    • Execute Logic Gates
    • MBE - Max's Block Entity
    • FMBE - A New Way to Create Display Entities
    • Look Detection
    • Movement Detections
    • Orbital Camera
  • Useful Creations
    • Custom Crafter
    • Multiplayer Position Rearrangement
      function
Concepts
  • contents.json
  • Emojis & Symbols
  • Molang
  • Namespaces
  • Overwriting Assets
  • Raw Text
  • Shaders
  • Sounds
  • Subpacks
  • Text and Localization
  • Texture Atlases
  • textures_list.json
Documentation
  • Shared Constructs
  • Advanced Molang
  • File Types
  • Fog IDs
  • Material Configuration Description
  • Menu Categories
  • Molang Queries
  • Pack Folder Structure
  • Sound Definitions
  • Vanilla Materials
Entities
  • General
    • Intro to Entities BP
      guide
    • Intro to Entities RP
      guide
    • Troubleshooting Entities
      help
    • Entity Events
    • Entity Properties
    • NPC Dialogues
    • Render Controllers
    • Spawn Rules
  • Tutorials
    • Convert Points Between Any Space (World, Entity, Bones)
    • Creating Boats
    • Detecting Other Entities
    • Disabling Team Damage
    • Dummy Entities
    • Entity Attacks
    • Entity Holds Item
    • Entity Movement
    • Entity Timers
    • Flying Entities
    • Introduction to AOE Clouds
    • Invulnerable Entities
    • Look at Entity
    • Sleeping Entities
    • Solid Entities
    • Spawning Tamed Entities
      Scripts
    • Village Mechanic
  • Documentation
    • Dummy Components
    • Non-Mob Runtime Identifiers
    • Projectiles
    • Runtime Identifiers
    • Vanilla Usage Components
    • Vanilla Usage Spawn Rules
Items
  • General
    • Intro to Items
      guide
    • Item Components
    • Item Tags
    • Item Events
      Scripts
    • Item Event Migration
      help
    • Troubleshooting Items
      help
  • Tutorials
    • Custom Armor
    • Custom Food
      Scripts
    • Custom Pottery Sherds
    • Custom Weapons
    • Equipment-Based Commands
    • High Resolution Items
    • Spawning Items
    • Throwable Items
  • Documentation
    • Enchantments
    • Attachables
    • Item Format History
    • Numerical Item IDs
    • Vanilla Item Identifiers
    • Vanilla Usage Components
JSON UI
  • General
    • Intro to JSON UI
      guide
    • Best Practices
      guide
  • Tutorials
    • Adding HUD Elements
    • Aseprite Animations
    • Buttons and Toggles
    • Modifying Server Forms
    • Preserve Title Texts
    • String to Number
  • Documentation
    • JSON UI Documentation
Loot, Recipes & Trading
  • General
    • Trading Behavior
  • Documentation
    • Loot Tables
    • Trade Tables
    • Recipes
    • Item Functions
  • Tutorials
    • Randomized Structure Loot
Meta
  • Add-On Performance
  • Style Guide
  • Useful Links
  • Using Schemas
  • Version Control
  • Q&A
    • Blocks and Items Q&A 2024/08/30
    • Deferred Technical Preview Q&A 2024/02/23
    • GameTest Q&A 2021/08/06
    • Scripting and Editor Q&A 2023/09/22
    • World Generation Q&A 2024/11/15
NBT
  • General
    • .mcstructure
  • Tutorials
    • Experiments in Education Edition
    • Extending Structure Limits
  • NBT in Depth
    • About NBT (Named Binary Tag)
    • NBT Libraries
    • Reading NBT Example
Particles
  • General
    • Intro to Particles
      guide
  • Tutorials
    • Disabling Particles
  • Documentation
    • Vanilla Particles
Scripting
  • General
    • Intro to Scripting
    • What is Script API?
    • API Modules
  • Tutorials
    • Block Placement Prevention
    • GameTests
    • Script Core Features
    • Script Forms
    • Script Requests API
    • Simple Chat Commands
  • Documentation
    • Engine Environment
    • Script Resources
    • Script Watchdog
    • Troubleshooting JavaScript
    • TypeScript
Servers
  • Software
    • Bedrock Server Software
  • Protocols
    • Bedrock Protocol
    • NetherNet Protocol
    • RakNet Protocol
Visuals
  • General
    • Introduction to Entity Visuals
      guide
    • Bedrock Modeling
    • Custom Death Animations
    • Effects in Animations
    • Material Creations
    • Materials
    • Math-Based Animations
    • Skin Packs
  • Tutorials
    • Entity Texture Animation
    • Glowing Entity Texture
    • Hurt Animations
    • Leash Position
    • Player Geometry
    • Remove Entity Shadows
    • Retexturing Spawn Eggs
  • Ideas
    • Structure Presentation
World Generation
  • General
    • Intro to World Generation
      guide
    • Biomes
      guide
    • Feature Types
  • Tutorials
    • Block Conditions for Features
    • Generating Custom Ores
    • Generating Custom Structures
    • Generating Patches
    • Heightmap Noise
  • Documentation
    • Biome Tags

Scoreboard Operations

Scoreboard Operations
  • Overview
  • Mathematical Operators
    • Addition
    • Subtraction
    • Multiplication
    • Floored Division
    • Floored Modulo Division
  • Logical Operators
    • Assignment Operator
    • Minimum Operator
    • Maximum Operator
    • Swap Operator
  • Useful Creations
    • Check If Values are Equal
    • Scoreboard Initialization

Scoreboards can be used to perform complex operations, similar to Molang. Operations come in two flavors: mathematical, and logical.

Overview ​

Operations are performed using the /scoreboard players operation command. The full syntax is laid out below:

yaml
/scoreboard players operation <targetScore> <objective> <operation> <sourceScore> <objective>
1

The command consists of two score holders: The target score, and the source score. The target score is the value being operated on, and the source score is the value affecting the operation. The result of the operation is written into the target score, and the source score's value is not touched, save for one operation.

Mathematical Operators ​

Mathematical operators use arithmetic to affect the target score. There are five mathematical operations available: addition, subtraction, multiplication, floor division, and floor modulo division.

For each of the following examples below, assume that score holder .A wiki:var equals 25, and .B wiki:var equals 10.

Addition ​

Operator: +=

This operation adds the target score and source scores together, then stores the sum into the target score.

yaml
/scoreboard players operation .A wiki:var += .B wiki:var
1

.A = .A + .B, and as such 25 + 10 = 35.

Subtraction ​

Operator: -=

This operation subtracts the target score by the source score, then stores the difference into the target score.

yaml
/scoreboard players operation .A wiki:var -= .B wiki:var
1

.A = .A - .B, and as such 25 - 10 = 15.

Multiplication ​

Operator: *=

This operation multiplies the target score by the source score, then stores the product into the target score.

yaml
/scoreboard players operation .A wiki:var *= .B wiki:var
1

.A = .A * .B, and as such 25 * 10 = 250.

Floored Division ​

Operator: /=

This operation divides the target score by the source score, then stores the quotient into the target score. Because score values can only be integers, the value is floored, or rounded down.

yaml
/scoreboard players operation .A wiki:var /= .B wiki:var
1

.A = floor(.A / .B), and as such floor(25 / 10) = 2.

Floored Modulo Division ​

Operator: %=

This operation also divides the target score by the source score, but instead returns the remainder after the division into the target score. This is also floored.

yaml
/scoreboard players operation .A wiki:var %= .B wiki:var
1

.A = floor(mod(.A, .B)), and as such floor(mod(25, 10)) = 5.

Logical Operators ​

Logical operations use logic gates and assignments to affect the target score. There are four logical operations available: assignment, less than, greater than, and swap.

Similar to the above, assume that score holder .A wiki:var equals 25, and .B wiki:var equals 10.

Assignment Operator ​

Operator: =

This operation sets the target score equal to the source score.

yaml
/scoreboard players operation .A wiki:var = .B wiki:var
1

.A = .B, and as such the result is 10.

Minimum Operator ​

Operator: <

This operation returns the smallest of the input scores, and stores it into the target score.

yaml
/scoreboard players operation .A wiki:var < .B wiki:var
1

.A = min(.A, .B), and as such min(25, 10) = 10.

Maximum Operator ​

Operator: >

This operation returns the largest of the input scores, and stores it into the target score.

yaml
/scoreboard players operation .A wiki:var > .B wiki:var
1

.A = max(.A, .B), and as such max(25, 10) = 25.

Swap Operator ​

Operator: ><

This operation swaps the target score and source scores with each other. This is the only operation that affects the source score.

yaml
/scoreboard players operation .A wiki:var >< .B wiki:var
1

The above command would swap the values of .A and .B e.g.

Before: .A = 10; .B = 25;

After: .A = 25; .B = 10;

This can be seen as three operations: .Temp = .A; .A = .B; .B = .Temp;, and as such .A wiki:var = 10 and .B wiki:var = 25.

Useful Creations ​

Check If Values are Equal ​

If you want to check in scoreboard, whether one value equals another value, you can use the following command:

yaml
scoreboard objectives add wiki:temp dummy
execute if score .Steve wiki:temp = .Alex wiki:temp run say Steve's score matches Alex's score.
1
2

Scoreboard Initialization ​

If you want to initialize a scoreboard value to 0, but only if it doesn't exists, you can use scoreboard players add <score holder> <objective> 0. It will set the value to 0, if it doesn't exist on the entity and do nothing, if it already exist.

Contributors

Edit Scoreboard Operations on GitHub

Bedrock Wiki by Bedrock OSS

"Minecraft" is a trademark of Mojang AB.

Bedrock OSS, Bedrock Wiki and bedrock.dev are not affiliated in any way with Microsoft or Mojang AB.

  • Privacy Policy
  • Join our Discord
  • Learn how to Contribute
  • Visit our Repository