Can't compare 'name of clicked item' with a text

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

Vini

Member
Apr 8, 2023
42
2
8
Hey!
So I have this booster skript I just started and it has some issues, I'm a starter skripter so I don't know much about skript.
It has the error: Can't compare 'name of clicked item' with a text:
on right-click with orange dye:
HERE --> if name of clicked item is "&b2x &eBooster &f| &b5 minutes":
remove 1 orange dye named "&b2x &eBooster &f| &b5 minutes" from player


command /booster 2x:
trigger:
give player orange dye named "&b2x &eBooster &f| &b5 minutes"

on right-click with orange dye:
if name of clicked item is "&b2x &eBooster &f| &b5 minutes":
remove 1 orange dye named "&b2x &eBooster &f| &b5 minutes" from player
if {booster::timer} is not set:
set {booster::timer} to 5 minutes
set {booster::multiplier} to 2
send "&aYou activated the 2x booster! It will last for 5 minutes."
else:
send "&cA booster is already active!"
 
do "if player's tool is blah:"

also, pleaseee dont use names as an indentifier, u can just name a piece of dirt that with an anvil and it'll work, use nbts, for example:

Code:
command /nbtgive:
  trigger:
    set {_i} to oak wood plank
    set {_icompound} to nbt compound of {_i}
    set tag "a" of {_icompound} to "b"
    # That is how you set the compound
on click:
  tool of player is oak wood plank:
    set {_itemcompound} to nbt compound of player's tool
    set {_itemtag} to tag "a" of {_itemcompound}.
    # (This checks if the nbt compound of it has that tag)
    {_itemtag} contains "b":
      # Your code
 
do "if player's tool is blah:"

also, pleaseee dont use names as an indentifier, u can just name a piece of dirt that with an anvil and it'll work, use nbts, for example:

Code:
command /nbtgive:
  trigger:
    set {_i} to oak wood plank
    set {_icompound} to nbt compound of {_i}
    set tag "a" of {_icompound} to "b"
    # That is how you set the compound
on click:
  tool of player is oak wood plank:
    set {_itemcompound} to nbt compound of player's tool
    set {_itemtag} to tag "a" of {_itemcompound}.
    # (This checks if the nbt compound of it has that tag)
    {_itemtag} contains "b":
      # Your code
?
 
What he's saying is there is a way to format your code. if you press the 2nd 3 dotted symbol that says more options, you should see an options that that looks like this: </> this is how you format code.

code_language.skript:
on right-click with orange dye:
    if player's tool's name is "&b2x &eBooster &f| &b5 minutes":
    remove 1 orange dye named "&b2x &eBooster &f| &b5 minutes" from player


command /booster 2x:
    trigger:
        give player orange dye named "&b2x &eBooster &f| &b5 minutes"

on right-click with orange dye:
    if name of clicked item is "&b2x &eBooster &f| &b5 minutes":
        remove 1 orange dye named "&b2x &eBooster &f| &b5 minutes" from player
        if {booster::timer} is not set:
            set {booster::timer} to 5 minutes
            set {booster::multiplier} to 2
            send "&aYou activated the 2x booster! It will last for 5 minutes."
        else:
            send "&cA booster is already active!"
 
What he's saying is there is a way to format your code. if you press the 2nd 3 dotted symbol that says more options, you should see an options that that looks like this: </> this is how you format code.

code_language.skript:
on right-click with orange dye:
    if player's tool's name is "&b2x &eBooster &f| &b5 minutes":
    remove 1 orange dye named "&b2x &eBooster &f| &b5 minutes" from player


command /booster 2x:
    trigger:
        give player orange dye named "&b2x &eBooster &f| &b5 minutes"

on right-click with orange dye:
    if name of clicked item is "&b2x &eBooster &f| &b5 minutes":
        remove 1 orange dye named "&b2x &eBooster &f| &b5 minutes" from player
        if {booster::timer} is not set:
            set {booster::timer} to 5 minutes
            set {booster::multiplier} to 2
            send "&aYou activated the 2x booster! It will last for 5 minutes."
        else:
            send "&cA booster is already active!"
what? no, i was explaining nbts