Solved Right-click shield

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

lunarenzox

Member
May 13, 2018
17
0
0
21
can anyone make a skript that if a player right click using a sword, shield will comeout on off-hand
 
code_language.skript:
on rightclick holding a sword:
    if shield of player is empty:
        set shield of player to shield
        stop
    if shield of player is a shield:
        set shield of player to air
        stop
 
@ShaneBee how i will make it so that players cannot duplicate it ? plss ? and if i switch to another slot where there's no sword the shield will gone
 
Ok give this a try. (You will need skellett for the hotbar switching)
I have set it so if the player moves to another item in their hot bar, the shield will disappear
I have also set it so if the player opens their inventory and clicks on the shield it will stop them and close their inventory.

If a player has their own shield, they can freely use it anyway they wish

code_language.skript:
on rightclick holding a sword:
    if shield of player is empty:
        set shield of player to shields named "&aSHIELD"
        stop
    if shield of player is a shields named "&aSHIELD":
        set shield of player to air
        stop

on hotbar switch:
    if slot 40 of player is a shields named "&aSHIELD":
        set slot 40 of player to air

on inventory click:
    if clicked item is a shield named "&aSHIELD":
        cancel event
        wait 1 tick
        close player's inventory
 
@ShaneBee there's a problem, everytime i will hold the right-click... its just repeating what it doing, like its not blocking, its like block and let go, block and let go, but im holding the right-click
 
Ok, I changed it, so now the player needs to "SNEAK" to be able to release their shield
code_language.skript:
on rightclick holding a sword:
    if shield of player is empty:
        set shield of player to shields named "&aSHIELD"
        stop
    if player is sneaking:
        if shield of player is a shields named "&aSHIELD":
            set shield of player to air
            stop

on hotbar switch:
    if slot 40 of player is a shields named "&aSHIELD":
        set slot 40 of player to air

on inventory click:
    if clicked item is a shield named "&aSHIELD":
        cancel event
        wait 1 tick
        close player's inventory