Skript [SkBee] Easy Tutorial for Scoreboards!

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

Jake

Supporter
Jan 30, 2022
217
14
18
18
Italy
github.com
Hello! If you're reading this tutorial then you probably need help making a scoreboard, don't worry, I'll teach you step by step how to make a clean Scoreboard without flickering.

IMPORTANT INFO
  • REQUIREMENTS: Skript, SkBee

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

  • IMPORTANT: If you have SkRayFall installed, go in its config file and the option "
    enableFastScoreBoards" from true to false
  • To actually start coding create a .sk file in the plugins/skript/scripts folder and write the code there.

  • 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)
  • Anything after a # is a comment and does not modify the code.
    EX
    Code:
    on chat:
      cancel event
      send "&cShhh" to player #this will send a message to the player
    
    #end of code
  • 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.
  • Scoreboard lines go from 1 to 15


  1. First we need an event:
    Code:
    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):
    Code:
    on join:
      while player is online:
        wait 1 tick

  3. 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:

    Code:
    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

  4. 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.

    Code:
    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:

  5. The first thing we're going to add now is %player%, now, what does this mean? It means YOUR name, or to be more clear, the player that is triggering the event.
    EX:

    Code:
    on chat:
      give 1 diamond to player #the player that sent a message gets 1 diamond :D

    Note: always put it between %% when in a text, so that skript knows you're trying to use the player in the text, otherwise just use

    Knowing this, we can create a dedicated scoreboard line just for it:

    Code:
    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


    The server IP can be added by just typing it in:

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

  6. 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:

    Code:
    on join:
      if {kills::%player's uuid%} is not set:
       set {kills::%player's uuid%} to 0
      while player is online:
       #rest of the code...

    This way, if the player joining is first joining or just joining after we added these lines in, 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%}%

    Code:
    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%}%"
       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? (next step)

  7. We need to write a totally different event after the on join one, like this:

    Code:
       ......
       set line 1 of player's scoreboard to "&7Server Ip: Play.MyServer.com"
       wait 1 second
    
    on death: # this is the new event!

    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 the VICTIM are players:

    Code:
    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:

    Code:
    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.
  • As a different event add this:

    Code:
    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.

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:
    EssentialsX
    Vault
    PlaceholderAPI
    Skript-Placeholder
  • Now follow these steps and memorize what you're doing:

  1. Run this command:
    /papi ecloud download vault

    ^Downloads the data of the vault placeholders

  2. Run this command:
    /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)

  3. 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!)

    Code:
    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
    
    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%}

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
 
By any chance am i able to create a timer that goes down in minutes that i can do /settimer 30 which will make a 30 minute timer on my scoreboard?