on inventory click i want item lore to change to something else and it should stays same

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

TheOriginal26

Member
Jun 2, 2023
1
0
1
20
So this is my skript, the problem is when I click the item its lore changes, and if I close inventory it goes back to the starting lore, what I want is the fix to it so that the lore stays until the player clicks it and it changes to next lore.

Thank you!!

Code:
command rankupshop:
    trigger:
        set {_g} to a chest inventory with 1 row named "&8Rank Up Shop"
        set slot 4 of {_g} to wheat named "&6Rank Up" with lore "" and "Click Me To Unlock The Rank" and "" and "&a500"
        open {_g} to player

on inventory click:
    if name of event-inventory is "&8Rank Up Shop":
        cancel event
        if clicked slot is 4:
            if group of player is "farmer-0":
                if line 4 of the lore of the item contains "&a500":
                    set line 4 of the lore of the item to "&a1K"
                    make player execute command "rankup"
                Else:
                    if group of player is "farmer-1":
                        if line 4 of the lore of the item contains "&a1k":
                            set line 4 of the lore of the item to "&a2.5K"
                            make player execute command "rankup"
                        Else:
                            if group of player is "farmer-2":
                                if line 4 of the lore of the item contains "&a2.5k":
                                    set line 4 of the lore of the item to "&a5K"
                                    make player execute command "rankup"
                                Else:
                                    if group of player is "farmer-3":
                                        if line 4 of the lore of the item contains "&a5K":
                                            set line 4 of the lore of the item to "&a10K"
                                            make player execute command "rankup"
                                        Else:
                                            if group of player is "farmer-4":
                                                if line 4 of the lore of the item contains "&a10K":
                                                    set line 4 of the lore of the item to "&a25K"
                                                    make player execute command "rankup"
                                                Else:
                                                    if group of player is "farmer-5":
                                                        if line 4 of the lore of the item contains "&a25K":
                                                            set line 4 of the lore of the item to "&a50K"
                                                            make player execute command "rankup"
 
So to make it so that the lore stays static, you can't just set the line of the lore of the clicked item, as that will only save so long the player never closes the GUI. What you'll have to do is store the lore you want into a variable. For example:
Code:
set {item.lore::%player%} to "&a$TestPrice" # Using a variable attached to player so it stays for any player.

What you can then do is a couple different things. One, you could just store the name of the lore you want directly in the variable. So your code would then look something like:
Code:
if line 4 of the lore of the item contains "&a25K":
                                                            set line 4 of the lore of the item to "%{item.lore::%player%}%" # Given that you set the 50k text value of the lore before this

However, another solution is using a function and assigning a numerical value to the item.lore variable. Then after a player clicks an item in a GUI, it adds 1 to the variable. You'd then check to see if the item.lore changes and to modify the lore as needed using potentially another variable (This could be more ineffective than just using the first solution I mentioned).