Note: In recent skBee updates the scoreboard syntax has switched from using the word(s) "scoreboard" to "fastboard", there is no difference in behavior, it can also be shortened with just "board" which is what we'll be using for the sake of simplicity.
Scoreboards are made of a title and 15 lines of text, the concept of dynamically creating them is very simple and it all starts when the player joins:
on join:
Many make the mistake of using this event with a while loop (or even worse a periodical event) and calling it a day, this is bad for a number of reasons, the main one being: you don't need to update the entire scoreboard continuously, all you NEED to do is update each scoreboard line (and/or the title) IF and WHEN the information in the respective line is updated, not following? Don't worry, we all love examples so here's one:
on join:
while player is online:
set title of player's board to "My Server"
set line 1 of player's board to "Money: %{money::%player's uuid%}%"
wait 1 tick
on join:
set title of player's board to "My Server"
set line 1 of player's board to "Money: %{money::%player's uuid%}%"
That's a good step in the right direction, but it comes with a flaw which needs to be addressed: redundancy.
A good rule of thumb when programming is that when doing something many times – whether it be the same task or slightly different – you should always do your best not to repeat yourself, this is called DRY (Don't Repeat Yourself), so if we were to update the first line of the board once that variable is updated, we should ensure it always happens that way and it's consistent, thankfully – functions exist! :)
If you don't understand functions here's a simple rundown: a function is a section of code that has a name (the name of the function, that is), parameters (or none; they are placed inside a pair of parentheses; each parameter has a name and a type, they are separated by a colon ":", when using more than one parameter you must separate them with a comma; additionally, parameters can have default values, but that's more advanced ) and an optional return value.
Example of a function:
function giveDiamond(selectedPlayers: players, amount: int): give players in {_selectedPlayers::*} {_amount} of diamond
Here's a very simple function approach that modifies the player's money variable while also keeping the board up to date with that very variable's value by using another function for the actual board modification:
# Note: for the sake of simplicity we are counting line 0 as the title
function board(player: player, lines: ints):
loop {_lines::*}:
if loop-value = 0:
set title of {_player}'s board to "My Server"
else if loop-value = 1:
set line 1 of {_player}'s board to "Money: %{money::%uuid of {_player}%}%"
function addMoney(player: player, increase: number):
increase {money::%uuid of {_player}%} by {_increase}
board({_player}, 1)
With this approach you never need to update the board – it does it by itself!
Moving forward this is what you should do to manage your scoreboards, and to help establish this concept, here is a more in-depth example:
# Note: for the sake of simplicity we are counting line 0 as the title
function board(player: player, lines: ints):
loop {_lines::*}:
if loop-value = 0:
set title of {_player}'s board to "&3&lMy Server"
continue
else if loop-value = 1 or 4:
set {_content} to " "
else if loop-value = 2:
set {_content} to "&3&l⎢&7 Money: &3$%{money::%uuid of {_player}%} ? 0%"
else if loop-value = 3:
set {_content} to "&3&l⎢&7 Rank: &3%{rank::%uuid of {_player}%} ? "Player"%"
else if loop-value = 5:
set {_content} to "&3mc.mynewserver.net"
if {_content} exists:
set line loop-value of {_player}'s board to {_content}
clear {_content}
function addMoney(player: player, increase: number):
increase {money::%uuid of {_player}%} by {_increase}
board({_player}, 2)
function setRank(player: player, newRank: string):
set {rank::%uuid of {_player}%} to {_newRank}
board({_player}, 3)
on join:
board(player, integers from 0 to 5) # 5 being the index of the biggest expected line, if your board has all 15, use that
Since 1.20.4 you can now use minecraft's number format, I won't bore you with the details, but it essentially means you can set the score of the board's lines (on the right), you simply need to set the line to two strings instead of one (Note: this way of doing it is specific to skBee, if you wish to use skript-scoreboards you'll have to use this expression), here is the updated example with a slightly different design to make use of this feature:
function board(player: player, lines: ints):
loop {_lines::*}:
if loop-value = 0:
set title of {_player}'s board to "&3&lMy Server"
continue
else if loop-value = 1 or 4:
set {_content::*} to " "
else if loop-value = 2:
set {_content::*} to "&3&l⎢&7 Money: &3$%{money::%uuid of {_player}%} ? 0%" and "&3&l⎢"
else if loop-value = 3:
set {_content::*} to "&3&l⎢&7 Rank: &3%{rank::%uuid of {_player}%} ? "Player"%" and "&3&l⎢"
else if loop-value = 5:
set {_content::*} to "&3mc.mynewserver.net"
if {_content::*} exists:
set line loop-value of {_player}'s board to {_content::*}
clear {_content::*}
function addMoney(player: player, increase: number):
increase {money::%uuid of {_player}%} by {_increase}
board({_player}, 2)
function setRank(player: player, newRank: string):
set {rank::%uuid of {_player}%} to {_newRank}
board({_player}, 3)
on join:
board(player, integers from 0 to 5)
Notes to the reader:
- AI has not been used to write any part of this tutorial, I just really like em and en dashes!
- This tutorial was made with the latest versions in mind.
- Enjoy this free knowledge, go out in the digital world of Minecraft and Skript and do your worst (well – actually – your best!).
Made with ❤️ for the community! ✝️
You must be logged in to comment
March 21, 2022, 10:36 a.m. - _tud ¶
you don't need PlaceholderAPI and skript-placeholder to use %player's balance%, you only need vault and an economy plugin
Aug. 10, 2022, 9:18 a.m. - J__00 ¶
Fixed, hmu if you see anything wrong!
March 30, 2022, 6:02 p.m. - Gab ¶
You also need to toggle the player's scoreboard on.
Aug. 10, 2022, 9:18 a.m. - J__00 ¶
I've been told by the Addon Dev himself that this is not required by default unless you toggle it off, are you sure about that?
Aug. 9, 2022, 4:52 p.m. - steveshat ¶
All together this is a pretty awful tutorial. Bad example for beginners.
Aug. 9, 2022, 4:59 p.m. - nylhus ¶
Instead of adding the section that sets the variables to 0 if they aren't set, I'd do it in when setting the scoreboard with
set line 3 of player's scoreboard to "&fKills: %{kills::%player's uuid%}% ? 0
Aug. 10, 2022, 9:17 a.m. - J__00 ¶
I didn't notice your comment but i added the otherwise expression while editing the tutorial, thanks for the criticism <3
Aug. 9, 2022, 5:07 p.m. - ShaneBee ¶
Much of the content here is inaccurate, and as the developer of the plugin as well as a member of the community who constantly needs to help people who have issues due to the inaccurate info here, I would like to see it updated.
a)
Untrue, a scoreboard does NOT need to be toggled. By default it is on.
b)
title should not be set in the while loop. Title should only be set once (before the loop), same with lines that don't change. All you're doing here is sending many unneeded packets to the player for things that aren't changing. With many players online, all you're doing is sending a lot of packets that contain no changes.
c)
This is extremely inaccurate. For starters, your code here is just setting the lines/title to null. Its not removing the scoreboard object.
Also, SkBee manages this internally. When the player quits, their scoreboard is deleted. So again, your code does nothing here.
These things are massively miss informing the community.
Aug. 10, 2022, 9:16 a.m. - J__00 ¶
I re did most of the tutorial and i'm 99% sure I fixed everything you said, let me know if there are any issues now!
Aug. 9, 2022, 6:31 p.m. - ShaneBee ¶
uuid only has 1 "i" not 2... the amount of people copy/pasting your tutorial, then asking why they get errors is climbing.
Aug. 10, 2022, 9:15 a.m. - J__00 ¶
Fixed!
Dec. 14, 2022, 9:30 a.m. - lebombjames ¶
how do u add ranks to the scoreboard
June 13, 2023, 10:56 a.m. - sulphinx ¶
Dont use intervals for scoreboards, use events.
Like when you receive, send or check your balance it updates your scoreboard.
Way better than having to create more threads for "while" sections.
April 2, 2025, 2:04 a.m. - Cyan_Husky ¶
This worked great for me. Thanks!