Solved Command on right click or F

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

Status
Not open for further replies.

CringeBoy

Active Member
May 20, 2021
65
0
6
Romania
Is there any way to execute a command on interacting with an acacia slab as example? Like if you press F or Right Click on it to execute a command.
 
for rightclick is simple:

Code:
on rightclick:
    if clicked block is acacia_slab:
        message "that's a slab allright" to event-player
        #run functions
might wanna check that you're not holding the block though, to prevent it fro triggering when placing.

if you want to include upside down or double slabs you need to put those in as well.
 
for rightclick is simple:

Code:
on rightclick:
    if clicked block is acacia_slab:
        message "that's a slab allright" to event-player
        #run functions
might wanna check that you're not holding the block though, to prevent it fro triggering when placing.

if you want to include upside down or double slabs you need to put those in as well.
But how I can prevent from happening this? I need that for multiple workbench's. Like if you placed the slab, then you open it with right click or F. But I don't want it to be openable by right clicking it from your inventory, only if its placed on ground.
 
But how I can prevent from happening this? I need that for multiple workbench's. Like if you placed the slab, then you open it with right click or F. But I don't want it to be openable by right clicking it from your inventory, only if its placed on ground.

It's really hard to understand you, "Tymen van Essen's" method should work perfectly. You want people to right click on an acacia slab to run a command, right?


Code:
on right click:
    if event-block is acacia slab item or upside-down acacia slab item:
        send "that's an acacia slab alright" to player
        #any code here
 
It's really hard to understand you, "Tymen van Essen's" method should work perfectly. You want people to right click on an acacia slab to run a command, right?


Code:
on right click:
    if event-block is acacia slab item or upside-down acacia slab item:
        send "that's an acacia slab alright" to player
        #any code here
But he said that I have to prevent people from holding the block. I need it so you can use it only if you place the slab on ground.
[doublepost=1621585551,1621584494][/doublepost]I am getting this also:

[ERROR] Can't compare a block with ('wooden slab item' or 'upside-down acacia slab item') (wb1.sk, line 2: if event-block is wooden slab item or upside-down acacia slab item:')

[Skript] Encountered 1 error while reloading wb1.sk!

 
But he said that I have to prevent people from holding the block. I need it so you can use it only if you place the slab on ground.
i mean that when you are placing a slab on top of, or next to another slab you rightclick that first slab. meaning you are both right clicking and placing that slab at that time.
the code i gave does not cancel the placing
it is like when placing a chest on top of a chest, you have to hold shift to not open the inventory, but wont place the block when not holding shift. my code would both place the block and run the command and ignores shift.

on your other error, you can try if this works: (it doesn't)

Code:
on right click:
    if event-block is acacia slab item or top acacia slab item:
        send "that's an acacia slab alright" to player
        #any code here
 
Last edited:
i mean that when you are placing a slab on top of, or next to another slab you rightclick that first slab. meaning you are both right clicking and placing that slab at that time.
the code i gave does not cancel the placing
it is like when placing a chest on top of a chest, you have to hold shift to not open the inventory, but wont place the block when not holding shift. my code would both place the block and run the command and ignores shift.

on your other error, you can try if this works:

Code:
on right click:
    if event-block is acacia slab item or top acacia slab item:
        send "that's an acacia slab alright" to player
        #any code here
I am still having same error
 
my bad, yeah you don't want to put 'item' in that line at all.
this one i tested though: and the first one i originally gave you works too for the normal slab.

Code:
on right click:
    if event-block is acacia slab or top acacia slab:
        send "that's an acacia slab alright" to player
        #any code here
 
my bad, yeah you don't want to put 'item' in that line at all.
this one i tested though: and the first one i originally gave you works too for the normal slab.

Code:
on right click:
    if event-block is acacia slab or top acacia slab:
        send "that's an acacia slab alright" to player
        #any code here
It worked. Thank you so much!
 
Status
Not open for further replies.