Loop bug?

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

DPPPPP

Member
Jul 22, 2023
27
0
1
25
Code:
    set {_inventory} to a chest inventory
    set metadata value "huntGUI" of {_p} to chest inventory with 7 rows with name "           &c%{_time}% seconds left!"
    set metadata value "huntGUI_IN" of {_p} to 1
    set {_item} to gray concrete with name "&aClick Me!"
    loop {_diff} times:
        set slot random integer between 0 and 51 of metadata value "huntGUI" of {_p} to {_item}
    open metadata value "huntGUI" of {_p} to {_p}
    set {_loopTimes} to {_time}
    set {_iteration} to 0
    loop {_loopTimes} times:
        if {_time} is 0:
            stop
        play sound "block.note_block.harp" to {_p}
    
    
        set {_iteration} to {_iteration} + 1
    
        wait 1 seconds
        set name of metadata value "huntGUI" of {_p} to "           &c%{_loopTimes} - {_iteration}% seconds left!"
        send "%{_time} - {_iteration}%" to {_p}




For some reason, this code does not function. I am trying to update the name of the inventory opened, and it works the first time, changing from 10 to 9, but then stays stuck at 9. I have no idea why this is happening and suspect it may be a nuance of Skript as a language. Any thoughts?
 
These are the pertinent sections of the code, as nothing else in the file impacts this specific inventory. I can send full code if neccessary.