How do I make it so a lever cannot work without a item with a specific name

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

LixLim

Member
Jul 27, 2023
1
0
1
So, I just been trying to find out how for my keycards for my minecraft server of making it so a lever on a specific block like red concrete and it would require a item with a name of "Clearance 4" kind of thing. I cannot find out how currently, please help me out!

Below is the skript I have currently.
on right click on lever:
if name of player's tool does not contain "&8&l[&9&l&oKEYCARD&8&l]&3 Clearance One" or "&8&l[&9&l&oKEYCARD&8&l]&2 Clearance Two" or "&8&l[&9&l&oKEYCARD&8&l]&6 Clearance Three" or "&8&l[&9&l&oKEYCARD&8&l]&4 Clearance Four" or "&8&l[&9&l&oKEYCARD&8&l]&0 Clearance Five" or "&8&l[&9&l&oKEYCARD&8&l]&8&o Master Keycard":
cancel event
send ""
send "&c&l! &eYou need at least &3Clearance One &ekeycard or higher to use this lever!"
send ""
play sound "block.anvil.land" at volume 1 at pitch 2 to player
wait 1 second
else:
send ""
send "&a&l! &eAccess granted"
send ""
play sound "block.note_block.bit" at volume 1 at pitch 1 to player
wait 2 second
 
dont use name as an indentifier. use nbts as an indentifier like I did below, you won't regret it, you can learn more on the skbee wiki

command /nbtgive:
trigger:
set {_i} to diamond sword
set {_icompound} to nbt compound of {_i}
set tag "a" of {_icompound} to "b"
# That is how you set the compound
tool of player is diamond sword:
set {_itemcompound} to nbt compound of player's helmet
set {_itemtag} to tag "a" of {_itemcompound}.
{_itemtag} contains "b":
# Your code
# (This checks if the nbt compound of it has that tag)
 
dont use name as an indentifier. use nbts as an indentifier like I did below, you won't regret it, you can learn more on the skbee wiki

command /nbtgive:
trigger:
set {_i} to diamond sword
set {_icompound} to nbt compound of {_i}
set tag "a" of {_icompound} to "b"
# That is how you set the compound
tool of player is diamond sword:
set {_itemcompound} to nbt compound of player's helmet
set {_itemtag} to tag "a" of {_itemcompound}.
{_itemtag} contains "b":
# Your code
# (This checks if the nbt compound of it has that tag)
NO CODEBLOCK DETECTED! EMERGENCY! ALARM!