Tutorial by: J__00


0.
Hello! If you're reading this tutorial then you probably need help making a scoreboard, if so don't worry, I'll teach you step by step how to make a clean Scoreboard without flickering.

0.1
REQUIREMENTS:
Skript
SkBee

0.2
List of plugins needed if you want the scoreboard to have currency:
Vault
PlaceholderAPI
Skript-Placeholder

0.3 IMPORTANT
If you have SkRayFall installed, go in its config file and change the scoreboard related option.

0.4 To actually start coding create a .sk file in the plugins/skript/scripts folder and write the code there.

0.5 Everytime you edit the code in the file, you need to save it and run this command in game or via console /Sk reload nameofthefile.sk (CASE SENSITIVE)

0.6 Anything after a # is a comment and does not modify the code.

0.7 A common mistake when using an On join event is to save, reload and expect it to change, on join means that you have to leave and JOIN back to see the changes.

0.8 Scoreboard lines go from 1 to 15

1.
First we need an event:

on join:

with this event the scoreboard will be set to the player everytime they join, but that won't happen by itselfwe need to add a:

2.
WHILE loop, which is a very useful condition and is used to make something constantly happen (WARNING: when using a while loop, ALWAYS put a "wait 1 tick" at the end, else the server will crash):

on join:
  while player is online:

makes the skript activate when a player joins and makes it stay active while the player is online.

3.
-A
A scoreboard does NOT require to be "created", you just have to set its title and lines which is what this step is about, let's start from the title:

on join:
  while player is online:
    set title of player's scoreboard to "&eMy Server" #it's up to you if you want to use color codes, this is just an example
    wait 1 second

3.
-B
After setting the title we need to set 1 or more lines, let's set 4 for now:
Note: Scoreboard lines start from 0, bigger numbers will go above their predecessor.

on join:
  while player is online:
    set title of player's scoreboard to "&eMy Server"
    set line 4 of player's scoreboard to "&a " #set a random color code and a space to set the line to a blank space. PS: You need to set different color codes or add more spaces for each blank line, there can't be 2 lines with the same exact name.
    set line 3 of player's scoreboard to "&fPlayer: "
    set line 2 of player's scoreboard to "&fKills: "
    set line 1 of player's scoreboard to "&7Server Ip:"
    wait 1 second

There! With just 5 short lines of code we added 4 lines to the scoreboard, you can go ahead and do the same process for all the other lines, but first let me show you how to actually add statistics like Kills or just your name, NEXT STEP:

4.
-A
The first thing we're going to add now is %player%, now, what does this mean? It means YOUR name, whenever an event is triggered and "player" is used in the following lines, the lines that used it will be about that player like

give 1 diamond to player #the player that triggered whatever leads to this line!

Note: always put it between %% when in a text, so that skript knows you're trying to use the player in the text.
Knowing this we can add it to the scoreboard line dedicated to the player name:

on join:
  while player is online:
    set title of player's scoreboard to "&eMy Server"
    set line 4 of player's scoreboard to "&a " #set a random color code and a space to set the line to a blank space. PS: You need to set different color codes or add more spaces for each blank line, there can't be 2 lines with the same exact name.
    set line 3 of player's scoreboard to "&fPlayer: &b%player%"
    set line 2 of player's scoreboard to "&fKills: "
    set line 1 of player's scoreboard to "&7Server Ip:"
    wait 1 second

4.
-B
The server IP can be manually added:

on join:
  while player is online:
    set title of player's scoreboard to "&eMy Server"
    set line 4 of player's scoreboard to "&a " #set a random color code and a space to set the line to a blank space. PS: You need to set different color codes or add more spaces for each blank line, there can't be 2 lines with the same exact name.
    set line 3 of player's scoreboard to "&fPlayer: &b%player%"
    set line 2 of player's scoreboard to "&fKills: "
    set line 1 of player's scoreboard to "&7Server Ip: Play.MyServer.com"
    wait 1 second

4.
-C

Now to the interesting part, kills, what's written here about kills can be used with deaths, it will later be shown how.

To add Kills we need skript to have a variable that equals to the amount of them the player has.
A variable is skript's way to save data, every variable has a name and a value:

Knowing this, we can now create a variable by adding a few lines before the while loop,
To create a variable we first need to decide if it's a global variable or a player variable, in this case we want a player variable , here's an example: {nameofthevariable::%player%} (the name of the variable is case sensitive) (if the value of the variable is important then put %player's uuid% instead of %player%, using the player's uuid stores data and tags it as data of that player even when he changes his minecraft name, if you use %player% with a player and they change their nick, the data will be attached to the old username.

Adding the variable creation to the "on join" event means that we need to check if the player joining arleady has a value for that variable, else the value will be overridden.
To do so let's add a condition to check if the variable is set for the joining player's uuid:

on join:
  if {kills::%player's uuid%} is not set:
    set {kills::%player's uuid%} to 0
  while player is online:
    ...

This way, if the player joining is first joining or just joining after we added these lines, we're setting their kills variable to 0; to make kills have sense, let's add deaths as well and let's add them to the scoreboard:

To add a variable in a text, just like the expressions, put it between %% Example: %{kills::%player's uuid%}%

on join:
  if {kills::%player's uuid%} is not set:
    set {kills::%player's uuid%} to 0
  if {deaths::%player's uuid%} is not set:
    set {deaths::%player's uuid%} to 0
  while player is online:
    set line 5 of player's scoreboard to "&a " 
    set line 4 of player's scoreboard to "&fPlayer: &b%player%"
    set line 3 of player's scoreboard to "&fKills: %{kills::%player's uuid%}%"
    set line 2 of player's scoreboard to "&fDeaths: %{deaths::%player's uuid%}%" #I've added one more line to add deaths.
    set line 1 of player's scoreboard to "&7Server Ip: Play.MyServer.com"
    wait 1 second

Just like that, it will display the kills and deaths count.

But how do these numbers go up? Simple:

5.
We need to write another event after the on join one, like this:

    ......
    set line 1 of player's scoreboard to "&7Server Ip: Play.MyServer.com"
    wait 1 second

on death:
  ......

What's going to happen is, we need skript to recognize who's getting killed and who's killing in this event, so we need to set anything to happen only if the ATTACKER and VICTIM are players:

on death:
  if attacker is a player:
    if victim is a player:
      ....

Great!
Now all we need to do is make it add 1 kill to the attacker and 1 death to the victim, just like before we're going to use uuids to avoid stats being lost on nickname change:

on death:
  if attacker is a player:
    if victim is a player:
      add 1 to {kills::%attacker's uuid%}
      add 1 to {deaths::%victim's uuiid%}

This will add actual stats to the scoreboard.

5.1
As a different event add this:

on disconnect:
  clear player's scoreboard

This will reduce Server Lag and will use less RAM as the server doesn't need to keep the player who left's scoreboard as data and will just clear it.

  1. ADDITIONAL
    Currency:
    If you want to add currency there are multiple ways to do it, but the easiest one is to use vault which has its own eco system.
    As mentioned at the beginning you will need:
    Vault
    PlaceholderAPI
    Skript-Placeholder

Now follow these steps and memorize what you're doing:

Run this command:
/papi ecloud download vault

^Downloads the data of the vault placeholders
Then:

/papi reload

^Adds the downloaded content to the server data (makes it usable)

[Skript-Placeholder] <- will just convert what Papi Downloaded about Vault into Skript expressions. (Nothing to do here)

Ok so, now that we have everything set up, let's add the variable for the player's balance: %player's balance%

(Normally the expression is different and has a different name but that would not work with skript and is why it's required to have skript-placeholder, thus searching for vault placeholders is useless if you're gonna copy paste them into the code, each most important placeholder has it's own skript version when using the previously mentioned skript addon, they're just written in a more "English" way, if you need them, try to find out what they are by yourself as it helps a lot when learning skript!)

on join:
  if {kills::%player's uuid%} is not set:
    set {kills::%player's uuid%} to 0
  if {deaths::%player's uuid%} is not set:
    set {deaths::%player's uuid%} to 0
  while player is online:
    set line 5 of player's scoreboard to "&fBalance: &e%player's balance%" #<<<<< EDITED LINE
    set line 4 of player's scoreboard to "&fPlayer: &b%player%"
    set line 3 of player's scoreboard to "&fKills: %{kills::%player's uuid%}%"
    set line 2 of player's scoreboard to "&fDeaths: %{deaths::%player's uuid%}%"
    set line 1 of player's scoreboard to "&7Server Ip: Play.MyServer.com"
    wait 1 second

....

And now you have a scoreboard that keeps track of your kills, deaths and balance.

Want something to get added? Leave a comment and i'll add as many features in the easiest way possible for beginners!

-J


Did you find J__00's tutorial helpful?


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

    |     
  • March 30, 2022, 6:02 p.m. - Gab  

    You also need to toggle the player's scoreboard on.

    |