I need help with my keycard doors

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

Radiosavage3

Member
Aug 13, 2025
1
0
1
My skript does somewhat work but when I use a keycard on the top part of the door it does not work, and the block has to be right under the door when I want it to be under the block the door is on, can someone help me? Here is the skript:

on right click on iron door:
if block under clicked block is green terracotta:
if name of player's held item is "&aKeycard LvL 1" or "&bKeycard LvL 2":
open clicked block
wait 1 second
close clicked block
else:
send "&4❗ &7You need &aKeycard Level 1 &7or higher to open this door!" to player
wait 1 second

on right click on iron door:
if block under clicked block is yellow terracotta:
if name of player's held item is "&bKeycard LvL 2":
open clicked block
wait 1 second
close clicked block
else:
send "&4❗ &7You need &bKeycard Level 2 &7or higher to open this door!" to player
wait 1 second

People say to use 'blockdata tag "half" of event-block' but I kinda forgot how to use it... and idk if i need to replace anything with it....
 
Hey just check if block under event-block is again iron door -> if yes check 2 blocks under, in your case:

Code:
on right click on iron door:
    if block under event-block is iron door:
        set {_blockUnder} to block below block below event-block
    else:
        set {_blockUnder} to block under event-block
    if {_blockUnder} = green terracotta:
        if name of player's held item is "&aKeycard LvL 1" or "&bKeycard LvL 2":
            open event-block
            wait 1 second
            close event-block
        else:
            send "&4❗ &7You need &aKeycard Level 1 &7or higher to open this door!" to player
            wait 1 second

on right click on iron door:
    if block under event-block is iron door:
        set {_blockUnder} to block below block below event-block
    else:
        set {_blockUnder} to block under event-block
    if {_blockUnder} = yellow terracotta:
        if name of player's held item is "&bKeycard LvL 2":
            open event-block
            wait 1 second
            close event-block
        else:
            send "&4❗ &7You need &bKeycard Level 2 &7or higher to open this door!" to player
            wait 1 second
Im not sure why exactly are you waiting after the message that player needs keycard of some level but okay.. It should work.
Also please next time paste it into the code section so its readable.
 
Here is a version with sound and it looks for the block above the iron door:

Code:
on right click on iron door:
    if block below event-block is iron door:
        set {_door} to block below event-block
    else:
        set {_door} to event-block

    set {_blockAbove} to block above block above {_door}

    if {_blockAbove} is lime wool:
        if name of player's held item is "&a&lLime Key" or "&x&3&7&A&F&D&8&lGuard Key":
            play sound "block.iron_door.open" at {_door} for player
            open {_door}
            wait 1 second
            play sound "block.iron_door.close" at {_door} for player
            close {_door}
        else:
            send "&4❗ &7You need a &aLime Keycard &7or higher to open this door!" to player

on right click on iron door:
    if block below event-block is iron door:
        set {_door} to block below event-block
    else:
        set {_door} to event-block

    set {_blockAbove} to block above block above {_door}

    if {_blockAbove} is blue wool:
        if name of player's held item is "&x&3&7&A&F&D&8&lGuard Key":
            play sound "block.iron_door.open" at {_door} for player
            open {_door}
            wait 1 second
            play sound "block.iron_door.close" at {_door} for player
            close {_door}
        else:
            send "&4❗ &7You need a &x&3&7&A&F&D&8Guard Keycard &r&7to open this door!" to player