Solved Why doesn't this work?

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

Quest1able

Member
Aug 6, 2023
16
1
3
24
Hi, I am very new to skript and am trying to code a loop where every 1.5 seconds, your level goes down by one. This is the code i've tried:

on join:
while player is online:
make console execute command "/experience add %player% -1 levels"
set {Player_XP} to player's level
wait 1.5 seconds

does anyone know why this doesnt work? If so, please tell me.
 
Hi, I am very new to skript and am trying to code a loop where every 1.5 seconds, your level goes down by one. This is the code i've tried:

on join:
while player is online:
make console execute command "/experience add %player% -1 levels"
set {Player_XP} to player's level
wait 1.5 seconds

does anyone know why this doesnt work? If so, please tell me.
The on join event makes it so your code only happens when a player joins. Also, you don't wanna remove a player's XP using a console command. The reasoning being it's a lot longer than a more simplistic alternative. To fix these issues:

Code:
options:
   ReXP: "true"

every 1.5 seconds:
   if {@ReXP} is "true":
      loop all players:
         subtract 1 from loop-player's xp # FYI; the 1 is how much XP you're removing, not levels
 
The on join event makes it so your code only happens when a player joins. Also, you don't wanna remove a player's XP using a console command. The reasoning being it's a lot longer than a more simplistic alternative. To fix these issues:

Code:
options:
   ReXP: "true"

every 1.5 seconds:
   if {@ReXP} is "true":
      loop all players:
         subtract 1 from loop-player's xp # FYI; the 1 is how much XP you're removing, not levels
Thank you very much. Sorry for the late reply though.
 
  • Like
Reactions: Luke_Sky_Walker