Every tick doesn't work with variable

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

TimeStellar

New Member
Mar 4, 2024
5
0
1
23
I am making a action bar for health and when i tried to show the variable it says that there is no player in a particular event

Here is the code

every 1 tick:
send action bar "&c%{myhp.%player%}%&7/&c%{mymaxhp.%player%}%" to players
 
Try this:
Code:
every 1 tick:
    loop all players:
        send action bar "&c%{myhp.%player%}%&7/&c%{mymaxhp.%player%}%" to loop-players
But I'm telling you up front If you've got a lot of people playing on your server and your server is not powerful you may feel performance reduction. Because Going through every single player every tick is kinda demanding for the server.
 
  • Like
Reactions: Luke_Sky_Walker
sent this error
 

Attachments

  • image_2024-03-05_182853464.png
    image_2024-03-05_182853464.png
    52.6 KB · Views: 18
Hm, thats strange, what version of skript are you using and addons?
 
the latest i downloaded and these addons
 

Attachments

  • image_2024-03-05_183247064.png
    image_2024-03-05_183247064.png
    1.8 KB · Views: 23
Instead of using %player% you have to use %loop-player%. I also suggest not to use it in the way you did, much rather update the action bar every 2 seconds and each time the player health bar changes.

Python:
every 2 seconds:
    loop all players:
        updateHealthBar(loop-player)

on heal:
    updateHealthBar(player)

on damage:
    updateHealthBar(player)

function updateHealthBar(p: player):
    send action bar "&c%{myhp.%{_p}%}%&7/&c%{mymaxhp.%{_p}%}%" to {_p}
 
Last edited: