Trying to make a teleportation wand

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

Status
Not open for further replies.
Aug 8, 2022
1
0
1
16
Hello! I am trying to make an item with an ability similar to the Aspect of the End in Hypixel Skyblock, however the way I am currently making it, the player will always teleport to the block 5 blocks ahead of them, however, if there is a block occupying that place, the player will become stuck in the wall and suffocate. Is there a way to make it so that the teleportation stops at the first solid block within range of the teleportation, so the player is not suffocated? Thanks!
Here is my current code:
on right click:
if name of player's held item is "&5Teleportation Wand":
set {_waited} to difference between {cooldown::%player%::Teleport} and now
if {_waited} is less than 1 seconds:
send "&cYou can use &6Teleport &cagain in %difference between {_waited} and 1 seconds%"
else:
set {cooldown::%player%::Teleport} to now
set {_loc} to location 5 blocks in front of player
teleport player to {_loc}
 
Next time please use code brackets
This loops 5 times and it won't teleport if the block in front is solid.

Code:
if name of player's held item is "&5Teleportation Wand":
    set {_waited} to difference between {cooldown::%player%::Teleport} and now
    if {_waited} is less than 1 seconds:
        send "&cYou can use &6Teleport &cagain in %difference between {_waited} and 1 seconds%"
    else:
        block at location 1 in front of player is solid:
            send "&cThere are blocks in the way!"
            stop
        set {cooldown::%player%::Teleport} to now
        loop 5 times:
            set {_loc} to location 1 in front of player
            {_loc} isn't solid
            teleport player to {_loc}
 
Status
Not open for further replies.