Cant unenchant armor

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

    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!

AQika

Member
Jun 28, 2023
31
3
8
Code:
on armor change:
    if event-item is enchanted with protection 4:
        loop enchantments of event-item:
            if loop-value is protection 4:
                set {_i} to loop-value
            else:
                add loop-value to {_enchants::*}
        disenchant event-item
        loop {_enchants::*}:
            enchant event-item with loop-value
        enchant event-item with protection 3

getting error that the event item cannot be changed

the idea is if armor on equip is with protection 4, enchant it with protection 3 instead
 
Code:
on armor change:
    if event-item is enchanted with protection 4:
        loop enchantments of event-item:
            if loop-value is protection 4:
                set {_i} to loop-value
            else:
                add loop-value to {_enchants::*}
        disenchant event-item
        loop {_enchants::*}:
            enchant event-item with loop-value
        enchant event-item with protection 3

getting error that the event item cannot be changed

the idea is if armor on equip is with protection 4, enchant it with protection 3 instead
You could just do this in like six lines. That would perhaps be a little more convenient. Keep in mind this has not been tested in game, it has no errors but may be impractical/undesirable:
Code:
on inventory click:
   if event-item is enchanted with protection 4:
      set {_i} to event-item # This is so we can store it as a variable to modify it with ease
      remove {_i} from player # Removes the target item from the player
      enchant {_i} with protection 3 # No need to disenchant or anything if we're just changing the enchantment
      give player {_i} # After being enchanted properly, it gives the player the proper item
 
Hey i tried doing what you showed me but for me it did not work, but i found a much more efficient solution for my problem thanks for giving the solution as it helped me in finding the solution to my problem! Have a nice day!
 
  • Like
Reactions: Luke_Sky_Walker