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.

Teleportation with blocks

Discussion in 'Skript' started by JustADev, Aug 20, 2017.

Thread Status:
Not open for further replies.
  1. JustADev

    JustADev Well-Known Member

    Joined:
    Apr 8, 2017
    Messages:
    380
    Likes Received:
    9
    Question: How do I make it so when a player right clicks the sword and teleports, that if there is a block in front of them, it will teleport them 1 block away from the block?

    Code:
    Code (Skript):
    1. on rightclick with diamond sword:
    2.     name of player's tool is "&eEnderman Sword":
    3.         set {_Waited} to difference between {Teleport::%player%} and now
    4.         if {_Waited} is less than 20 seconds:
    5.             stop
    6.         else:
    7.             set {AbilityInUse} to "True"
    8.             send "&cAbility &8&l» &7You have activated your &aTeleport &7ability" to player
    9.             set {Teleport::%player%} to now
    10.             set {_Block} to block 4 in front of player
    11.             play "ENDERMAN_TELEPORT" to player at volume 1
    12.             teleport player above {_Block}
     
  2. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,181
    Likes Received:
    220
    Which portion of the code doesn't work and are there any errors? You've posted here enough to know the drill by now huh? ;3
     
  3. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,181
    Likes Received:
    220
    Ok, the code I created is 100% perfect, Its just finding a way so that if there is a block in front of the player, it won't teleport them through it

    Example:
    o = you
    - = block on ground
    | = 2 high block stack

    o--|-
    I dont want them to teleport through it.
    I tried looping the blocks above {_Block} in a radius
    But It didnt work, no errors though

    Code (Skript):
    1. on rightclick with diamond sword:
    2.     name of player's tool is "&eEnderman Sword":
    3.         set {_Waited} to difference between {Teleport::%player%} and now
    4.         if {_Waited} is less than 20 seconds:
    5.             stop
    6.         else:
    7.             set {AbilityInUse} to "True"
    8.             send "&cAbility &8&l» &7You have activated your &aTeleport &7ability" to player
    9.             set {Teleport::%player%} to now
    10.             set {_Block} to block 4 in front of player
    11.             loop all blocks in radius 4 of {_Block}:
    12.                 if loop-block is block 1 above {_Block}:
    13.                     cancel event
    14.                 else:
    15.                     play "ENDERMAN_TELEPORT" to player at volume 1
    16.                     teleport player above {_Block}
     
  4. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,181
    Likes Received:
    220
    If I under you correctly could you not just check if the loop block in a radius or vector is not air and if not cancel it?
     
Thread Status:
Not open for further replies.

Share This Page

Loading...