Problem with looping, even though there is no loop...

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

memes

Member
Jun 24, 2018
23
2
3
24
So this is my skript, pretty much it will keep on looping until {_n} is 1... I have no clue why...
Code:
on damage:
    if attacker is player:
        if victim is player:
            if victim is not attacker:
                set {_e::*} to enchantments of attacker's tool
                if "%{_e::*}%" contains "Knockback" or "punch":
                    if slot 8 of victim's inventory is an eye of ender:
                        set {_l} to lore of slot 8 of victim's inventory
                        replace all "&7Uses: &d&n" in {_l} with ""
                        set {_n} to {_l} parsed as integer
                        remove 1 from {_n}
                        broadcast "%{_n}%"
                        if {_n} > 0:
                            set slot 8 of victim's inventory to eye of ender of mending 1 named "&d&lCHARM &8| &5Anti-Knockback" with lore "&7Uses: &d&n%{_n}%"
                            cancel event
                            make attacker damage victim by damage
                            send "&d&lCHARMS &8| &7%victim% has used their anti-knockback charm." to attacker
                            send "&d&lCHARMS &8| &7You have used your anti-knockback charm! &7Uses: &d&n%{_n}%" to victim
                            stop
 
You stated "make attacker damage victim by damage" which repeats the damage event. You are basically recursively triggering the damage event until the condition is not met anymore 'if {_n} > 0'. I don't know why you are canceling the event tbh.
 
Last edited:
Status
Not open for further replies.