Solved problems with loop player

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

Status
Not open for further replies.

BoxMiners

Member
Jul 19, 2022
47
0
6
18
Code:
every 3 seconds:
 loop all players:
  if {cookie.%loop-player%} is set:
   wipe loop-player's sidebar
   set name of sidebar of loop-player to "&a&lCookies"
   set score "&6----------------------" in sidebar of loop-player to 8
   set score "&6|" in sidebar of loop-player to 7
   set score "&6| Cookies: &a%{cookies.%player%}%" in sidebar of loop-player to 6
   set score "&6| Cursers: &a%{curser.%player%}%" in sidebar of loop-player to 5
   set score "&6| Grandmas: &a%{grandma.%player%}%" in sidebar of loop-player to 4
   set score "&6| Cookie Mine: &a%{cookmine.%player%}%" in sidebar of loop-player to 3
   set score "&6|" in sidebar of loop-player to 2
   set score "&6----------------------" in sidebar of loop-player to 1

So i was making a skript for a sidebar, but i ran into a problem. The weird thing is that the 8th and the 2nd works fine but everything else doesnt work :/ (i used skrayfall)
[doublepost=1661866868,1661866817][/doublepost]
upload_2022-8-30_15-41-6.png
 
The syntax is different. This is how it's done using SkBee.

Code:
set line 1 of player's scoreboard to "text here"

And also a loop is not the best way to update a scoreboard.

You can just edit the line affected by a change. For example, if your scoreboard displays currency, you can edit the line when the player's currency is updated.

If a lot of information is going to change, it would be tedious to edit the right line each time. So, you can make a function that updates the full scoreboard of an input player. So you'll be able to run the function every time a change is made in a player's scoreboard which will update the entire scoreboard with the most up-to-date information. It's for me the best method, adapted to most situations.

And to fix the error you have, change %player% to %loop-player% in your variables. Also best to use player's uuid instead of just player so their progress doesn't get reset after a name change
 
The syntax is different. This is how it's done using SkBee.

Code:
set line 1 of player's scoreboard to "text here"

And also a loop is not the best way to update a scoreboard.

You can just edit the line affected by a change. For example, if your scoreboard displays currency, you can edit the line when the player's currency is updated.

If a lot of information is going to change, it would be tedious to edit the right line each time. So, you can make a function that updates the full scoreboard of an input player. So you'll be able to run the function every time a change is made in a player's scoreboard which will update the entire scoreboard with the most up-to-date information. It's for me the best method, adapted to most situations.

And to fix the error you have, change %player% to %loop-player% in your variables. Also best to use player's uuid instead of just player so their progress doesn't get reset after a name change
thanks so much it really helps
 
Status
Not open for further replies.