Teleportation with blocks

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

Status
Not open for further replies.

JustADev

Well-Known Member
Apr 8, 2017
379
9
18
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_language.skript:
on rightclick with diamond sword:
    name of player's tool is "&eEnderman Sword":
        set {_Waited} to difference between {Teleport::%player%} and now
        if {_Waited} is less than 20 seconds:
            stop
        else:
            set {AbilityInUse} to "True"
            send "&cAbility &8&l» &7You have activated your &aTeleport &7ability" to player
            set {Teleport::%player%} to now
            set {_Block} to block 4 in front of player
            play "ENDERMAN_TELEPORT" to player at volume 1
            teleport player above {_Block}
 
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
 
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_language.skript:
on rightclick with diamond sword:
    name of player's tool is "&eEnderman Sword":
        set {_Waited} to difference between {Teleport::%player%} and now
        if {_Waited} is less than 20 seconds:
            stop
        else:
            set {AbilityInUse} to "True"
            send "&cAbility &8&l» &7You have activated your &aTeleport &7ability" to player
            set {Teleport::%player%} to now
            set {_Block} to block 4 in front of player
            loop all blocks in radius 4 of {_Block}:
                if loop-block is block 1 above {_Block}:
                    cancel event
                else:
                    play "ENDERMAN_TELEPORT" to player at volume 1
                    teleport player above {_Block}
 
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?
 
Status
Not open for further replies.