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 Timers

Scoreboard Timers
  • Introduction
  • Setup
  • System
  • Explanation
  • Defining Events with Limited Occurances
  • Executing Commands During Intervals
  • Entity Timers

Introduction ​

Sourced by the Bedrock Commands Community (BCC) Discord

This system allows you to run your desired commands at precise intervals, allowing for customizable delays as per your requirements.

Some Examples:

  • Sending a message in chat every 2 hours.
  • Running a 'lag clear' function every 10 minutes.
  • Effecting players with 'speed' every 30 seconds.

This system is particularly useful for managing multiple timers in your world. When working with command blocks, you may use the Tick Delay option to delay the time taken for your commands to run. However, when working with functions, you will need to use a system like this.

It is recommended to use this system while working with command blocks, as well if you wish to run all your world-timers in sync with one another, i.e., with the same start time.

Setup ​

To be typed in chat:

yaml
/scoreboard objectives add wiki:ticks dummy
/scoreboard objectives add wiki:events dummy
1
2

After creating these objectives, the next step is to define the interval for each repeating event using the ticks objective.

To do that, first, you must know that 1 second is approximately 20 game-ticks in Minecraft. Based on this knowledge, you will need to do some basic calculations to obtain the equivalent ticks for each interval you want to define.

yaml
# 2h = 20t × 60s × 60m × 2h = 144000t
/scoreboard players set .2h wiki:ticks 144000

# 10m = 20t × 60s × 10m = 12000t
/scoreboard players set .10m wiki:ticks 12000

# 30s = 20t × 30s = 600t
/scoreboard players set .30s wiki:ticks 600
1
2
3
4
5
6
7
8

With the scoreboard data set, we can now operate our timers based on the intervals defined.

System ​

BP/functions/wiki/scoreboard/world_timer.mcfunction
yaml
## World Timer/Clock
### Increment +1 tick
scoreboard players add .Timer wiki:ticks 1
### Apply current ticks passed to all events
scoreboard players operation * wiki:events = .Timer wiki:ticks

## Chat Message (every 2h)
scoreboard players operation .ChatMessage wiki:events %= .2h wiki:ticks
execute if score .ChatMessage wiki:events matches 0 run say Technoblade never dies!

## Lag Clear (every 10m)
scoreboard players operation .LagClear wiki:events %= .10m wiki:ticks
execute if score .LagClear wiki:events matches 0 run function clear_lag

## Speed Effect (every 30s)
scoreboard players operation .SpeedEffect wiki:events %= .30s wiki:ticks
execute if score .SpeedEffect wiki:events matches 0 run effect @a speed 10 2 true
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

Chain of 8 Command Blocks

Here, we have taken 3 examples to show how to implement them, but you can add any timer you prefer and as many as you need.

Just make sure to follow the given order and properly apply the /execute if score condition as shown for your desired commands.

Explanation ​

wiki:events — On this objective, we label all the repeating events we want on our world:

  • .ChatMessage
  • .LagClear
  • .SpeedEffect

Note: All 3 are score holders in the objective.

wiki:ticks — On this objective, we define all the intervals for our events and also run our scoreboard timer:

  • .2h interval (static score: 144000)
  • .10m interval (static score: 12000)
  • .30s interval (static score: 600)
  • .Timer clock (variable score: n+1)

Note: All 4 are score holders in the objective.

Command 1: This command adds +1 score every tick to the score holder .Timer indicating a tick has passed in the game. This is basically our scoreboard timer/clock which we will use for all the repeating events on our world.

Command 2: Here, we copy '.Timer' score to all our events using the * wildcard selector. This will allow us to perform operations to determine if the interval has been reached to run the commands for that particular event. Example:

  • If .Timer score is 1200, it means 1200 game-ticks have passed.
  • This command makes it so all our events score holders (.ChatMessage, .LagClear, .SpeedEffect) scores are also 1200.

Command 3: We will use the %= modulo operation to check if our event scores are divisible by their assigned interval. i.e., if the remainder is equal to 0.

  • Chat Message: 1200/144000
    • Q=0, R=1200 — interval not reached.
  • Lag Clear: 1200/12000
    • Q=0, R=1200 — interval not reached.
  • Speed Effect: 1200/600
    • Q=2, R=0 — interval reached.
    • Hence, commands for the .SpeedEffect event can be executed.

Here, we can note that the .ChatMessage and .LagClear events are yet to happen, but the .SpeedEffect event is happening for the second time.

Note: In Minecraft, scoreboard division is floored, i.e., it's only calculated up to whole numbers and decimal values are ignored.

Command 4: the remainder obtained from the calculation is applied to the corresponding event's score holder. Based on this knowledge, we can run our commands if it's score is equal to 0.

The remaining commands follow the same structure, with only the event labels and interval durations modified.

Defining Events with Limited Occurances ​

To limit how many times an event occurs, you need to create a new objective called wiki:occurances and define how many times that event should occur, as shown below.

yaml
/scoreboard objectives add wiki:occurances dummy
/scoreboard players set .ChatMessage wiki:occurances 5
/scoreboard players set .SpeedEffect wiki:occurances 10
1
2
3

Once you have done that, modify your system as shown below.

BP/functions/wiki/scoreboard/world_timer.mcfunction
yaml
## World Timer/Clock
### Increment +1 tick
scoreboard players add .Timer wiki:ticks 1
### Apply current time to all events
scoreboard players operation * wiki:events = .Timer wiki:ticks

## Chat Message (every 10m)
scoreboard players operation .ChatMessage wiki:events %= .2h wiki:ticks
execute if score .ChatMessage wiki:events matches 0 if score .ChatMessage wiki:occurances matches 1.. run say Technoblade never dies!
execute if score .ChatMessage wiki:events matches 0 if score .ChatMessage wiki:occurances matches 1.. run scoreboard players remove .ChatMessage wiki:occurances 1

## Speed Effect (every 30s)
scoreboard players operation .SpeedEffect wiki:events %= .30s wiki:ticks
execute if score .SpeedEffect wiki:events matches 0 if score .SpeedEffect wiki:occurances matches 1.. run effect @a speed 10 2 true
execute if score .SpeedEffect wiki:events matches 0 if score .SpeedEffect wiki:occurances matches 1.. run scoreboard players remove .SpeedEffect wiki:occurances 1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

Chain of 8 Command Blocks

Executing Commands During Intervals ​

To run commands continuously between the intervals of an event, you may use the technique shown below.

yaml
## Speed Effect (every 30s) + Particle (every tick)
scoreboard players operation .SpeedEffect wiki:events %= .30s wiki:ticks
execute if score .SpeedEffect wiki:occurances matches 1.. as @a at @s run particle minecraft:shulker_bullet ~~~
execute if score .SpeedEffect wiki:events matches 0 if score .SpeedEffect wiki:occurances matches 1.. run effect @a speed 10 2 true
execute if score .SpeedEffect wiki:events matches 0 if score .SpeedEffect wiki:occurances matches 1.. run scoreboard players remove .SpeedEffect wiki:occurances 1
1
2
3
4
5

As shown in line 3, to run commands while the timer is running, all you need to do is remove the if score condition testing if all occurances took place. And instead, only test if any occurance remains, to run our commands.

Let's say we had set the wiki:occurances for this event to 10. Then players would've also had a particle trail for 300 seconds as repeating a 30s event 10 times will total 300 seconds.

Entity Timers ​

In some cases, such as an entity despawn event, you will need to run timers for each entity separately rather than a synchronised timer which could cause the event to trigger too soon. In such cases, an Async Timer can be helpful.

Let's say we want to perform the following actions:

  1. kill all entities named "wiki:station" 5 minutes after they've been summoned.
  2. play a shulker particle around them during that timeframe.
  3. play a flame particle around them in the first 10 seconds.
  4. play a pling sound to nearby players when the timer reaches half way.
  5. stop the timer if a passive mob is nearby.
  6. loop the timer if a hostile mob is nearby.
BP/functions/wiki/scoreboard/players/entity_timer.mcfunction
yaml
## Running the Timer
scoreboard players add @e[name="wiki:station",scores={wiki:ticks=0..}] wiki:ticks 1

# Executing Commands While Timer Is Running
execute as @e[name="wiki:station",scores={wiki:ticks=0..}] at @s run particle minecraft:shulker_bullet ~~~

# Executing Commands Within a Timeframe
execute as @e[name="wiki:station",scores={wiki:ticks=0..200}] at @s run particle minecraft:basic_flame_particle ~~~

# Executing Commands at Precise Intervals
execute as @e[name="wiki:station",scores={wiki:ticks=3600}] at @s run playsound note.pling @a[r=10]

# Stopping the Timer
execute as @e[name="wiki:station"] at @s if entity @e[family=pacified,r=10,c=1] run scoreboard players set @s ticks -1

# Looping the Timer
execute as @e[name="wiki:station",scores={wiki:ticks=6000}] at @s if entity @e[family=monster,r=10,c=1] run scoreboard players set @s ticks 0

# End of Timer
kill @e[name="wiki:station",scores={wiki:ticks=6000}]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

Chain of 7 Command Blocks

As shown, setting the score to 0 when it completes the timeframe will loop the timer. And setting the score to -1 will stop/disable it. You can still set the score to 0 to start the timer again.

Contributors

Edit Scoreboard Timers 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