How to random teleport in a radius of 100 blocks around the player?

  • 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.
This should be in requests but here's a rough outline
code_language.skript:
set {_block} to random element out of blocks in radius 100 of player
teleport player to {_block}'s location
 
Something like...
code_language.skript:
loop all blocks in radius 100 around player:
    y-coordinate of loop-block is higher or equal to 64 #To avoid the player to be teleported into a cave
    block above loop-block is air #to avoid teleporting into a block
    block below loop-block is air #^^ ^^ ^^
    apply resistance 7 to player for 10 seconds #to avoid death via fall damage
    teleport player to location of loop-block
    stop loop

The problem is that looping blocks in a radius selects them from the nearest to the furthest, so it would teleport the player 1 block above itself. Talk about inconvenience.

So if you could get a way to make the loop get random blocks, everything would work wonders.
 
Status
Not open for further replies.