Solved Making a scoreboard

  • 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!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

xWires

Member
Aug 15, 2023
41
4
8
Hello! I need to make a scoreboard that is different for each player. I used this code previously but it isn't working anymore. Can someone help me fix this code?

Code:
every 2 second:
    loop all players:
        wipe loop-player's sidebar
        set name of sidebar of loop-player to "&6&lWiredGens"
        set score "&r  &8&m--------" in sidebar of loop-player to 9
        set score "&1Balance:&f <BALANCE> " in sidebar of loop-player to 8
        set score " &1Gen slots:&f <GENSLOTS>" in sidebar of loop-player to 7
        set score "&2" in sidebar of loop-player to 6
        set score "&2&nServer" in sidebar of loop-player to 5
        set score " &1Joins: &f<SJOINS>" in sidebar of loop-player to 4
        set score "&1Items Sold:&f <SISOLD>" in sidebar of loop-player to 3
        set score " &4Tokens:&f <TBALANCE>" in sidebar of loop-player to 2
        set score "  &8&m--------" in sidebar of loop-player to 1
 
Hello! I need to make a scoreboard that is different for each player. I used this code previously but it isn't working anymore. Can someone help me fix this code?

Code:
every 2 second:
    loop all players:
        wipe loop-player's sidebar
        set name of sidebar of loop-player to "&6&lWiredGens"
        set score "&r  &8&m--------" in sidebar of loop-player to 9
        set score "&1Balance:&f <BALANCE> " in sidebar of loop-player to 8
        set score " &1Gen slots:&f <GENSLOTS>" in sidebar of loop-player to 7
        set score "&2" in sidebar of loop-player to 6
        set score "&2&nServer" in sidebar of loop-player to 5
        set score " &1Joins: &f<SJOINS>" in sidebar of loop-player to 4
        set score "&1Items Sold:&f <SISOLD>" in sidebar of loop-player to 3
        set score " &4Tokens:&f <TBALANCE>" in sidebar of loop-player to 2
        set score "  &8&m--------" in sidebar of loop-player to 1
Hey there! Just a recommendation, but you probably will not want to run your code every two seconds as that can be laggy and not super effective (As due to the delay, when a player's stats get updated, it'll look a bit choppy). You would wanna change your code to only run when it's absolutely needed to. To do this, simply make it set the scoreboard for the player when they first join like this:

Code:
on first join:
     wipe player's sidebar
     set name of sidebar of player to "&6&lWiredGens"
     set score "&r  &8&m--------" in sidebar of player to 9
     set score "&1Balance:&f <BALANCE> " in sidebar of player to 8
     set score " &1Gen slots:&f <GENSLOTS>" in sidebar of player to 7
     set score "&2" in sidebar of player to 6
     set score "&2&nServer" in sidebar of player to 5
     set score " &1Joins: &f<SJOINS>" in sidebar of player to 4
     set score "&1Items Sold:&f <SISOLD>" in sidebar of player to 3
     set score " &4Tokens:&f <TBALANCE>" in sidebar of player to 2
     set score "  &8&m--------" in sidebar of player to 1

However, you may notice the scoreboard doesn't update when a player buys/sells an item. Instead of setting the new designated scores every time a player buys a new item (Which would take up a ton of lines), what you can do instead is create a function for the scoreboard. Here's a quick example of this:

Code:
function updscore(p: player):
   set name of sidebar of {_p} to "This is an updated scoreboard!"
You can then call this function in any event needed to show/update a scoreboard for a player (You can also use it on the join event & save yourself even more lines of code)! This will also cause scores to appear to update faster than in your original code.
 
Hey there! Just a recommendation, but you probably will not want to run your code every two seconds as that can be laggy and not super effective (As due to the delay, when a player's stats get updated, it'll look a bit choppy). You would wanna change your code to only run when it's absolutely needed to. To do this, simply make it set the scoreboard for the player when they first join like this:

Code:
on first join:
     wipe player's sidebar
     set name of sidebar of player to "&6&lWiredGens"
     set score "&r  &8&m--------" in sidebar of player to 9
     set score "&1Balance:&f <BALANCE> " in sidebar of player to 8
     set score " &1Gen slots:&f <GENSLOTS>" in sidebar of player to 7
     set score "&2" in sidebar of player to 6
     set score "&2&nServer" in sidebar of player to 5
     set score " &1Joins: &f<SJOINS>" in sidebar of player to 4
     set score "&1Items Sold:&f <SISOLD>" in sidebar of player to 3
     set score " &4Tokens:&f <TBALANCE>" in sidebar of player to 2
     set score "  &8&m--------" in sidebar of player to 1

However, you may notice the scoreboard doesn't update when a player buys/sells an item. Instead of setting the new designated scores every time a player buys a new item (Which would take up a ton of lines), what you can do instead is create a function for the scoreboard. Here's a quick example of this:

Code:
function updscore(p: player):
   set name of sidebar of {_p} to "This is an updated scoreboard!"
You can then call this function in any event needed to show/update a scoreboard for a player (You can also use it on the join event & save yourself even more lines of code)! This will also cause scores to appear to update faster than in your original code.
Thank you, but the balances are updated by a plugin and not a skript, so I don't think I would be able to do it like that.
 
  • Like
Reactions: Luke_Sky_Walker
skbee has its own scoreboards, download it or if you already have it,

Code:
function scoreboardExample(p: player):
    set title of {_p}'s scoreboard to ""
    set line 1 of {_p}'s scoreboard to ""
 
skbee has its own scoreboards, download it or if you already have it,

Code:
function scoreboardExample(p: player):
    set title of {_p}'s scoreboard to ""
    set line 1 of {_p}'s scoreboard to ""
Thank you!