Detect if player is holding an item with a specific NBT

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

Jul 18, 2023
27
0
1
16
Hi there! I'm making a lightsaber Skript and it has a custom NBT. I'm trying to make it so when you hold the sword and deal damage to an entity it does damage. The error is that it's detecting the unbreakable NBT, and it doesn't think it's the damage item. Here is my code:

Code:
command /lightsabercraft:
    trigger:
        if player's inventory contains 25 netherite blocks:
            send "&bScanning for items..."
            wait 2 seconds
            send "&aSuccessfully crafted!"
            set {saber::%player's uuid%} to stone sword named "&bLightsaber" with lore "&aA weapon from a more civilized age." with custom model data 6
            give unbreakable {saber::%player's uuid%} to player
        else:
            send "&bScanning for items..."
            wait 2 seconds
            send "&cYou need 25 netherite blocks for this!"
on damage:
    if attacker is holding stone sword named "&bLightsaber" with lore "&aA weapon from a more civilized age." with custom model data 6:
        set damage to 20
    else:
        set damage to 1

All help is appreciated! :emoji_grinning: