1. 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!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Skript [SkBee] Easy Tutorial for Scoreboards!

Discussion in 'Tutorials' started by Jake*, Feb 13, 2022.

  1. Jake*

    Supporter

    Joined:
    Jan 30, 2022
    Messages:
    109
    Likes Received:
    6
    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 (Text):
      1. on chat:
      2.   cancel event
      3.   send "&cShhh" to player #this will send a message to the player
      4.  
      5. #end of code
      6.  
    • 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 (Text):
      1. 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 (Text):
      1. on join:
      2.   while player is online:
      3.     wait 1 tick
      4.  
    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 (Text):
      1. on join:
      2.   while player is online:
      3.    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
      4.    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 (Text):
      1. on join:
      2.   while player is online:
      3.    set title of player's scoreboard to "&eMy Server"
      4.    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.
      5.    set line 3 of player's scoreboard to "&fPlayer: "
      6.    set line 2 of player's scoreboard to "&fKills: "
      7.    set line 1 of player's scoreboard to "&7Server Ip:"
      8.    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 (Text):
      1. on chat:
      2.   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 (Text):
      1. on join:
      2.   while player is online:
      3.    set title of player's scoreboard to "&eMy Server"
      4.    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.
      5.    set line 3 of player's scoreboard to "&fPlayer: &b%player%"
      6.    set line 2 of player's scoreboard to "&fKills: "
      7.    set line 1 of player's scoreboard to "&7Server Ip:"
      8.    wait 1 second

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

      Code (Text):
      1. 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 (Text):
      1. on join:
      2.   if {kills::%player's uuid%} is not set:
      3.    set {kills::%player's uuid%} to 0
      4.   while player is online:
      5.    #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 (Text):
      1. on join:
      2.   if {kills::%player's uuid%} is not set:
      3.    set {kills::%player's uuid%} to 0
      4.   if {deaths::%player's uuid%} is not set:
      5.    set {deaths::%player's uuid%} to 0
      6.   while player is online:
      7.    set line 5 of player's scoreboard to "&a "
      8.    set line 4 of player's scoreboard to "&fPlayer: &b%player%"
      9.    set line 3 of player's scoreboard to "&fKills: %{kills::%player's uuid%}%"
      10.    set line 2 of player's scoreboard to "&fDeaths: %{deaths::%player's uuid%}%"
      11.    set line 1 of player's scoreboard to "&7Server Ip: Play.MyServer.com"
      12.    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 (Text):
      1.    ......
      2.    set line 1 of player's scoreboard to "&7Server Ip: Play.MyServer.com"
      3.    wait 1 second
      4.  
      5. 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 (Text):
      1. on death:
      2.   if attacker is a player:
      3.    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 (Text):
      1. on death:
      2.   if attacker is a player:
      3.    if victim is a player:
      4.      add 1 to {kills::%attacker's uuid%}
      5.      add 1 to {deaths::%victim's uuiid%}
      This will add actual stats to the scoreboard.
    • As a different event add this:

      Code (Text):
      1. on disconnect:
      2.   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 (Text):
      1. on join:
      2.   if {kills::%player's uuid%} is not set:
      3.    set {kills::%player's uuid%} to 0
      4.   if {deaths::%player's uuid%} is not set:
      5.    set {deaths::%player's uuid%} to 0
      6.   while player is online:
      7.    set line 5 of player's scoreboard to "&fBalance: &e%player's balance%" #<<<<< EDITED LINE
      8.    set line 4 of player's scoreboard to "&fPlayer: &b%player%"
      9.    set line 3 of player's scoreboard to "&fKills: %{kills::%player's uuid%}%"
      10.    set line 2 of player's scoreboard to "&fDeaths: %{deaths::%player's uuid%}%"
      11.    set line 1 of player's scoreboard to "&7Server Ip: Play.MyServer.com"
      12.    wait 1 second
      13.  
      14. on death:
      15.   if attacker is a player:
      16.    if victim is a player:
      17.      add 1 to {kills::%attacker's uuid%}
      18.      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
     
  2. JacobWilliamsX

    JacobWilliamsX New Member

    Joined:
    Jun 11, 2021
    Messages:
    5
    Likes Received:
    0
    Thanks for the tutorial man. Was really helpful
     
  3. Jake*

    Supporter

    Joined:
    Jan 30, 2022
    Messages:
    109
    Likes Received:
    6
    <3
     

Share This Page

Loading...