1. The Command Syntax
To trigger the script, use the following format in your Minecraft chat or a command block:
/scriptevent my:db <source> <destination> <range>
<source>: The name of the scoreboard that has all the scores.
<destination>: The name of the scoreboard where you want to show the filtered results.
<range>: The "rule" for which scores should be moved.
2. How to write the "Range" rule
The checkRange function in your script allows for four different ways to filter scores:
| What you want |
Syntax Example |
Meaning |
| Minimum Score |
1.. |
Keep everyone with a score of 1 or higher. |
| Maximum Score |
..-1 |
Keep everyone with a score of -1 or lower. |
| Specific Range |
1..10 |
Keep everyone between 1 and 10 inclusive. |
| Exact Match |
5 |
Keep only players with exactly 5. |
3. Step-by-Step Example
Let’s say you have a hidden scoreboard called total_kills and you want to show a "Leaderboard" on the sidebar that only shows players with at least 5 kills.
- Create your boards (one-time setup):
/scoreboard objectives add total_kills dummy
/scoreboard objectives add leaderboard dummy "Top Slayers"
/scoreboard objectives setdisplay sidebar leaderboard
- Run the script command:
/scriptevent my:db total_kills leaderboard 5..
What happens next:
The script looks at total_kills. Anyone with 5+ kills is copied to leaderboard. Anyone with 4 or fewer is instantly removed from the sidebar so it stays clean.
4. Important Tips
- Case Sensitivity: Scoreboard names must match exactly (e.g.,
Kills is not the same as kills).
- Fake Players: This script works perfectly for fake player names (like "NPC_1") because it uses
getScores(), which catches every entry on the board.
- Automation: If you want this to happen automatically without typing the command, put the
/scriptevent command in a Repeating Command Block set to "Always Active."