1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help: save placed block names in variable

Discussion in 'Skript' started by Neocky, Sep 15, 2021.

  1. Neocky

    Neocky Member

    Joined:
    Sep 15, 2021
    Messages:
    1
    Likes Received:
    0
    Hello,

    i want to save the name of custom heads in a variable when placed and use them for some if statements when broken.
    This is currently my script and the message on place just says <nothing>:

    Code (Text):
    1. on place of player head:
    2.   message "%name of event-block%" to player
    3.   if name of event-block is "&6Cow":
    4.     set {%location%.Block_Name} to name of event-block
    5.  
    6.  
    7. on break of player head:
    8.   if {%location%.Block_Name} is "&6Cow":
    9.     send ":)"
    10.  
    Does anyone know why i can't get the name of the player head when being placed?
     
  2. oToghty

    VIP Supporter +

    Joined:
    Sep 1, 2020
    Messages:
    39
    Likes Received:
    2
    Blocks do not have names, you have to check the name of the tool
     
  3. timeis

    timeis Member

    Joined:
    May 19, 2021
    Messages:
    3
    Likes Received:
    0
    use %block's type%
     
  4. TheCubPlays

    TheCubPlays Member

    Joined:
    Jun 22, 2021
    Messages:
    33
    Likes Received:
    3
    Code (Text):
    1. if name of player's tool contains  "&6Cow":
    Basically that's all you need to do for the placement part, you can do the exact same thing with the breaking part aka the variable part:
    Code (Text):
    1. set {%location%.Block_Name} to name of player's tool
    The logic seems fine, just note that blocks don't have names so event-block wouldn't work in this case. Also use "contains" instead of "is", sometimes "is" is too accurate for it to work.
    Code (Text):
    1. if {%location%.Block_Name} contains "&6Cow":
    If that makes any sense
     

Share This Page

Loading...