Block's UUID in a variable

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

Jul 18, 2023
40
1
8
17
Hi there! I was just wondering how you'd put a block's UUID inside a variable. I'm trying to give the block data (a variable) when right clicked on by a certain item. I have to use %block's uuid%, but that's not working. If I used %player's uuid% that wouldn't work either, since only admins are able to set keycard levels on observers. If you could help that'd be awesome! Thank you!


Full Keycard Skript:

Code:
on right click on observer:
    if player is holding white dye named "&aKeycard &7[L1]" with lore "&7Right click on an observer to open a door.":
        if {cardreaderone::%block's uuid%} is true:
            send action bar "&aAccess Granted!" to player
            activate block west of block
            activate block east of block
            activate block north of block
            activate block south of block
        else:
            send action bar "&cAccess Denied. &4&lLevel 1 Required" to player
on right click on observer:
    if player is holding black dye named "&aKeycard &7[L2]" with lore "&7Right click on an observer to open a door.":
        if {cardreadertwo::%block's uuid%} is true:
            send action bar "&aAccess Granted!" to player
            activate block west of block
            activate block east of block
            activate block north of block
            activate block south of block
        else:
            send action bar "&cAccess Denied. &4&lLevel 2 Required" to player
on right click on observer:
    if player is holding gray dye named "&aKeycard &7[L3]" with lore "&7Right click on an observer to open a door.":
        if {cardreaderfour::%block's uuid%} is true:
            send action bar "&aAccess Granted!" to player
            activate block west of block
            activate block east of block
            activate block north of block
            activate block south of block
        else:
            send action bar "&cAccess Denied. &4&lLevel 3 Required" to player
on right click on observer:
    if player is holding yellow dye named "&aKeycard &7[L4]" with lore "&7Right click on an observer to open a door.":
        if {cardreaderfive::%block's uuid%} is true:
            send action bar "&aAccess Granted!" to player
            activate block west of block
            activate block east of block
            activate block north of block
            activate block south of block
        else:
            send action bar "&cAccess Denied. &4&lLevel 4 Required" to player
on right click on observer:
    if player is holding orange dye named "&aKeycard &7[L5]" with lore "&7Right click on an observer to open a door.":
        if {cardreaderfive::%block's uuid%} is true:
            send action bar "&aAccess Granted!" to player
            activate block west of block
            activate block east of block
            activate block north of block
            activate block south of block
        else:
            send action bar "&cAccess Denied. &4&lLevel 5 Required" to player
on right click on observer:
    if player is holding green dye named "&aKeycard &7[L6]" with lore "&7Right click on an observer to open a door.":
        if {cardreadersix::%block's uuid%} is true:
            send action bar "&aAccess Granted!" to player
            activate block west of block
            activate block east of block
            activate block north of block
            activate block south of block
        else:
            send action bar "&cAccess Denied. &4&lLevel 6 Required" to player
on left click on observer:
    if player is holding iron axe named "&bKeycard Setter &7[L1]":
        set {cardreaderone::%block's uuid%} to true
        send "&aAdded &bL1 &ato keycard reader!" to player
on left click on observer:
    if player is holding iron axe named "&bKeycard Setter &7[L2]":
        set {cardreadertwo::%block's uuid%} to true
        send "&aAdded &bL2 &ato keycard reader!" to player
on left click on observer:
    if player is holding iron axe named "&bKeycard Setter &7[L3]":
        set {cardreaderthree::%block's uuid%} to true
        send "&aAdded &bL3 &ato keycard reader!" to player
on left click on observer:
    if player is holding iron axe named "&bKeycard Setter &7[L4]":
        set {cardreaderfour::%block's uuid%} to true
        send "&aAdded &bL4 &ato keycard reader!" to player
on left click on observer:
    if player is holding iron axe named "&bKeycard Setter &7[L5]":
        set {cardreaderfive::%block's uuid%} to true
        send "&aAdded &bL5 &ato keycard reader!" to player
on left click on observer:
    if player is holding iron axe named "&bKeycard Setter &7[L6]":
        set {cardreadersix::%block's uuid%} to true
        send "&aAdded &bL6 &ato keycard reader!" to player
command /keycard:givekeycardsetters:
    permission: op
    trigger:
        give player iron axe named "&bKeycard Setter &7[L1]"
        give player iron axe named "&bKeycard Setter &7[L2]"
        give player iron axe named "&bKeycard Setter &7[L3]"
        give player iron axe named "&bKeycard Setter &7[L4]"
        give player iron axe named "&bKeycard Setter &7[L5]"
        give player iron axe named "&bKeycard Setter &7[L6]"
command /keycard:givekeycards:
    permission: op
    trigger:
        give player white dye named "&aKeycard &7[L1]" with lore "&7Right click on an observer to open a door."
        give player black dye named "&aKeycard &7[L2]" with lore "&7Right click on an observer to open a door."
        give player gray dye named "&aKeycard &7[L3]" with lore "&7Right click on an observer to open a door."
        give player yellow dye named "&aKeycard &7[L4]" with lore "&7Right click on an observer to open a door."
        give player orange dye named "&aKeycard &7[L5]" with lore "&7Right click on an observer to open a door."
        give player green dye named "&aKeycard &7[L6]" with lore "&7Right click on an observer to open a door."
 
That should work. Just use the event blocks location.

Code:
on right click on observer:
    if player is holding white dye named "&aKeycard &7[L1]" with lore "&7Right click on an observer to open a door.":
        if {cardreaderone::%event-block's location%} is set:
            send action bar "&aAccess Granted!" to player
            activate block west of block
            activate block east of block
            activate block north of block
            activate block south of block
        else:
            send action bar "&cAccess Denied. &4&lLevel 1 Required" to player
on right click on observer:
    if player is holding black dye named "&aKeycard &7[L2]" with lore "&7Right click on an observer to open a door.":
        if {cardreadertwo::%event-block's location%} is set:
            send action bar "&aAccess Granted!" to player
            activate block west of block
            activate block east of block
            activate block north of block
            activate block south of block
        else:
            send action bar "&cAccess Denied. &4&lLevel 2 Required" to player
on right click on observer:
    if player is holding gray dye named "&aKeycard &7[L3]" with lore "&7Right click on an observer to open a door.":
        if {cardreaderfour::%event-block's location%} is set:
            send action bar "&aAccess Granted!" to player
            activate block west of block
            activate block east of block
            activate block north of block
            activate block south of block
        else:
            send action bar "&cAccess Denied. &4&lLevel 3 Required" to player
on right click on observer:
    if player is holding yellow dye named "&aKeycard &7[L4]" with lore "&7Right click on an observer to open a door.":
        if {cardreaderfive::%event-block's location%} is set:
            send action bar "&aAccess Granted!" to player
            activate block west of block
            activate block east of block
            activate block north of block
            activate block south of block
        else:
            send action bar "&cAccess Denied. &4&lLevel 4 Required" to player
on right click on observer:
    if player is holding orange dye named "&aKeycard &7[L5]" with lore "&7Right click on an observer to open a door.":
        if {cardreaderfive::%event-block's location%} is set:
            send action bar "&aAccess Granted!" to player
            activate block west of block
            activate block east of block
            activate block north of block
            activate block south of block
        else:
            send action bar "&cAccess Denied. &4&lLevel 5 Required" to player
on right click on observer:
    if player is holding green dye named "&aKeycard &7[L6]" with lore "&7Right click on an observer to open a door.":
        if {cardreadersix::%event-block's location%} is set:
            send action bar "&aAccess Granted!" to player
            activate block west of block
            activate block east of block
            activate block north of block
            activate block south of block
        else:
            send action bar "&cAccess Denied. &4&lLevel 6 Required" to player
on left click on observer:
    if player is holding iron axe named "&bKeycard Setter &7[L1]":
        set {cardreaderone::%event-block's location%} to true
        send "&aAdded &bL1 &ato keycard reader!" to player
on left click on observer:
    if player is holding iron axe named "&bKeycard Setter &7[L2]":
        set {cardreadertwo::%event-block's location%} to true
        send "&aAdded &bL2 &ato keycard reader!" to player
on left click on observer:
    if player is holding iron axe named "&bKeycard Setter &7[L3]":
        set {cardreaderthree::%event-block's location%} to true
        send "&aAdded &bL3 &ato keycard reader!" to player
on left click on observer:
    if player is holding iron axe named "&bKeycard Setter &7[L4]":
        set {cardreaderfour::%event-block's location%} to true
        send "&aAdded &bL4 &ato keycard reader!" to player
on left click on observer:
    if player is holding iron axe named "&bKeycard Setter &7[L5]":
        set {cardreaderfive::%event-block's location%} to true
        send "&aAdded &bL5 &ato keycard reader!" to player
on left click on observer:
    if player is holding iron axe named "&bKeycard Setter &7[L6]":
        set {cardreadersix::%event-block's location%} to true
        send "&aAdded &bL6 &ato keycard reader!" to player
command /keycard:givekeycardsetters:
    permission: op
    trigger:
        give player iron axe named "&bKeycard Setter &7[L1]"
        give player iron axe named "&bKeycard Setter &7[L2]"
        give player iron axe named "&bKeycard Setter &7[L3]"
        give player iron axe named "&bKeycard Setter &7[L4]"
        give player iron axe named "&bKeycard Setter &7[L5]"
        give player iron axe named "&bKeycard Setter &7[L6]"
command /keycard:givekeycards:
    permission: op
    trigger:
        give player white dye named "&aKeycard &7[L1]" with lore "&7Right click on an observer to open a door."
        give player black dye named "&aKeycard &7[L2]" with lore "&7Right click on an observer to open a door."
        give player gray dye named "&aKeycard &7[L3]" with lore "&7Right click on an observer to open a door."
        give player yellow dye named "&aKeycard &7[L4]" with lore "&7Right click on an observer to open a door."
        give player orange dye named "&aKeycard &7[L5]" with lore "&7Right click on an observer to open a door."
        give player green dye named "&aKeycard &7[L6]" with lore "&7Right click on an observer to open a door."
 
That should work. Just use the event blocks location.

Code:
on right click on observer:
    if player is holding white dye named "&aKeycard &7[L1]" with lore "&7Right click on an observer to open a door.":
        if {cardreaderone::%event-block's location%} is set:
            send action bar "&aAccess Granted!" to player
            activate block west of block
            activate block east of block
            activate block north of block
            activate block south of block
        else:
            send action bar "&cAccess Denied. &4&lLevel 1 Required" to player
on right click on observer:
    if player is holding black dye named "&aKeycard &7[L2]" with lore "&7Right click on an observer to open a door.":
        if {cardreadertwo::%event-block's location%} is set:
            send action bar "&aAccess Granted!" to player
            activate block west of block
            activate block east of block
            activate block north of block
            activate block south of block
        else:
            send action bar "&cAccess Denied. &4&lLevel 2 Required" to player
on right click on observer:
    if player is holding gray dye named "&aKeycard &7[L3]" with lore "&7Right click on an observer to open a door.":
        if {cardreaderfour::%event-block's location%} is set:
            send action bar "&aAccess Granted!" to player
            activate block west of block
            activate block east of block
            activate block north of block
            activate block south of block
        else:
            send action bar "&cAccess Denied. &4&lLevel 3 Required" to player
on right click on observer:
    if player is holding yellow dye named "&aKeycard &7[L4]" with lore "&7Right click on an observer to open a door.":
        if {cardreaderfive::%event-block's location%} is set:
            send action bar "&aAccess Granted!" to player
            activate block west of block
            activate block east of block
            activate block north of block
            activate block south of block
        else:
            send action bar "&cAccess Denied. &4&lLevel 4 Required" to player
on right click on observer:
    if player is holding orange dye named "&aKeycard &7[L5]" with lore "&7Right click on an observer to open a door.":
        if {cardreaderfive::%event-block's location%} is set:
            send action bar "&aAccess Granted!" to player
            activate block west of block
            activate block east of block
            activate block north of block
            activate block south of block
        else:
            send action bar "&cAccess Denied. &4&lLevel 5 Required" to player
on right click on observer:
    if player is holding green dye named "&aKeycard &7[L6]" with lore "&7Right click on an observer to open a door.":
        if {cardreadersix::%event-block's location%} is set:
            send action bar "&aAccess Granted!" to player
            activate block west of block
            activate block east of block
            activate block north of block
            activate block south of block
        else:
            send action bar "&cAccess Denied. &4&lLevel 6 Required" to player
on left click on observer:
    if player is holding iron axe named "&bKeycard Setter &7[L1]":
        set {cardreaderone::%event-block's location%} to true
        send "&aAdded &bL1 &ato keycard reader!" to player
on left click on observer:
    if player is holding iron axe named "&bKeycard Setter &7[L2]":
        set {cardreadertwo::%event-block's location%} to true
        send "&aAdded &bL2 &ato keycard reader!" to player
on left click on observer:
    if player is holding iron axe named "&bKeycard Setter &7[L3]":
        set {cardreaderthree::%event-block's location%} to true
        send "&aAdded &bL3 &ato keycard reader!" to player
on left click on observer:
    if player is holding iron axe named "&bKeycard Setter &7[L4]":
        set {cardreaderfour::%event-block's location%} to true
        send "&aAdded &bL4 &ato keycard reader!" to player
on left click on observer:
    if player is holding iron axe named "&bKeycard Setter &7[L5]":
        set {cardreaderfive::%event-block's location%} to true
        send "&aAdded &bL5 &ato keycard reader!" to player
on left click on observer:
    if player is holding iron axe named "&bKeycard Setter &7[L6]":
        set {cardreadersix::%event-block's location%} to true
        send "&aAdded &bL6 &ato keycard reader!" to player
command /keycard:givekeycardsetters:
    permission: op
    trigger:
        give player iron axe named "&bKeycard Setter &7[L1]"
        give player iron axe named "&bKeycard Setter &7[L2]"
        give player iron axe named "&bKeycard Setter &7[L3]"
        give player iron axe named "&bKeycard Setter &7[L4]"
        give player iron axe named "&bKeycard Setter &7[L5]"
        give player iron axe named "&bKeycard Setter &7[L6]"
command /keycard:givekeycards:
    permission: op
    trigger:
        give player white dye named "&aKeycard &7[L1]" with lore "&7Right click on an observer to open a door."
        give player black dye named "&aKeycard &7[L2]" with lore "&7Right click on an observer to open a door."
        give player gray dye named "&aKeycard &7[L3]" with lore "&7Right click on an observer to open a door."
        give player yellow dye named "&aKeycard &7[L4]" with lore "&7Right click on an observer to open a door."
        give player orange dye named "&aKeycard &7[L5]" with lore "&7Right click on an observer to open a door."
        give player green dye named "&aKeycard &7[L6]" with lore "&7Right click on an observer to open a door."
Just FYI for the OP and for future reference; that's not the most efficient code. The commands at the bottom can be shortened a ton (You could use both variables and functions to cut their length down by at least half, maybe more). You could also likely shorten the code for checking if a player clicks either left or right on an observer. A general rule of thumb to consider when you see long code with similar repeating conditions/segments is that it can likely be turned into a function (Which allows you to run a single block of code for one event rather than use tons of similar code a bunch of time which is slower).