GUI right click event

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

Steven F

Member
Apr 9, 2017
10
0
0
25
Hi,

Is there any way to detect a right click in a GUI and run an alternate function/command if the user right clicked?

For example a shop where left click is buy and right click is sell.

Thanks!
 
on right click with chest:
open chest with (number) rows named " " to player
wait 1 tick
format slot 3 of player with (id/block) named " " to close then run/to run [execute player command "command"]
format slot 4 of player with (id/block) named " " to close then run/to run [execute player command "command"]
format slot 5 of player with (id/block) named " " to close then run/to run [execute player command "command"]
format slot 6 of player with (id/block) named " " to close then run/to run [execute player command "command"]
 
on right click with chest:
open chest with (number) rows named " " to player
wait 1 tick
format slot 3 of player with (id/block) named " " to close then run/to run [execute player command "command"]
format slot 4 of player with (id/block) named " " to close then run/to run [execute player command "command"]
format slot 5 of player with (id/block) named " " to close then run/to run [execute player command "command"]
format slot 6 of player with (id/block) named " " to close then run/to run [execute player command "command"]

Hmm I'm looking for actually right clicking an item within the GUI and calling a function :emoji_stuck_out_tongue:
 
code_language.skript:
command /open:
    trigger:
        open chest with 6 rows named "&4&lExample" to player
        set slot 22 of player's current inventory to a nametag named "Name" with lore "lore"
 
on inventory click:
    if inventory name of player's current inventory is "&4&lExample":
        cancel event
        if clicked slot is 22:
            if clicked type is right mouse button:
                functionRight(player)
            else if clicked type is left mouse button:
                functionLeft(player)
SkQuery and Bensku's Skript
 
  • Like
Reactions: BotiSteve
code_language.skript:
command /open:
    trigger:
        open chest with 6 rows named "&4&lExample" to player
        set slot 22 of player's current inventory to a nametag named "Name" with lore "lore"
 
on inventory click:
    if inventory name of player's current inventory is "&4&lExample":
        cancel event
        if clicked slot is 22:
            if clicked type is right mouse button:
                functionRight(player)
            else if clicked type is left mouse button:
                functionLeft(player)
SkQuery and Bensku's Skript
Very helpful, thanks!
 
Status
Not open for further replies.