What's wrong with this script?

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

Status
Not open for further replies.

Raenzil

Member
Jan 23, 2023
2
0
1
22
I am trying to make a script that prevent players to click an iron sword that doesn't have custom model data. But the script below will always cancel the clicking no matter the clicked sword has a custom model data or not. I wonder what could be wrong in the codes?

Script Version: 2.6.3

Minecraft Version: 1.19.3

Full Code:
Code:
on inventory click at iron sword:
    send "1!"
    if event-item doesn't have custom model data:
        send "2!"
        cancel event

Other Useful Info:
Server Version: Purpur 1.19.3-1900

No addons using

Have you tried searching the docs? Yes.
Have you tried searching the Forums? Yes.
What other methods have you tried to fix it?
I also tried the example of On Inventory Click event in the doc:
Code:
on inventory click:
    if event-item is stone:
        give player 1 stone
and it don't work for me too. Nothing happens when clicking a stone.
 
Last edited:
when looking for an inventory click, you want to check the event-slot. examples of this could be:
Code:
on inventory click:
    if index of event-slot = 10:
        send "clicked the 10th slot of this inventory"
    if event-slot is an iron ingot:
        send "this slot is an iron ingot"
    else:
        send "this slot is an %event-slot%"
If you look at the skhub docs, https://skripthub.net/docs/?id=1090
You can see that event-item does not exist. to get the item type, you use event-slot.
 
Status
Not open for further replies.