How to remove a item

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

Ceekay

New Member
Nov 16, 2024
5
0
1
So im trying to make a skript that has a custom item that whenever you use it does something then deletes itself from your inventory. How do i make a skript that does that
 
For a post like this, you would want to be in the request thread, as this is not where you want to be if you don't have any code for me to help you with, and you haven't tried it yourself.

Regardless, I will still help you with this task

This is the syntax I will be using. (I only included expressions and effects.)

Expressions:
Custom Model Data (to make sure that the item that we're gonna be using and deleting will always be the correct item)
Tool
Inventory
Targeted Block (example purposes)
Distance (example purposes)



Effects:
Change
Teleport (example purposes)

You can try to figure it out yourself using what's listed here.

Here is the code anyway:
Code:
on load:
    # Creates a custom iron sword item with a name, lore, and custom model data
    set {custom.item} to iron sword with name "Special Sword" with lore "Right click me!" with custom model data 3
 
command /givecustomitem:
    # Adds alternative command names
    aliases: gci, gcitem
    trigger:
        # Gives the custom item to the player who executed the command
        give player {custom.item}
    
on right click:
    # Checks if the held item has the specific custom model data (3)
    if player's held item has custom model data 3:
        # Checks if player is looking at a block
        if target block is set:
            # Gets the location of the block player is looking at
            set {_l} to location of targeted block
            # Ensures teleport distance is within 250 blocks
            distance between player and {_l} is less than 250
            # Checks if there's enough space to teleport (2 blocks of air)
            block above {_l} is air
            2 blocks above {_l} is air
            # Teleports player to the block above where they're looking
            teleport player to block above {_l}
            # Consumes the item after use
            remove player's held item from player's inventory

Let me know if you need any more help.