Hey this script wasn't made by me so don't give me any credit, but hopefully this helps!
options:
#Minimum amount of blocks farm from X cord to tp to
min.x: -500
#maximum amount of blocks farm from X cord to tp to
max.x: 500
#Minimum amount of blocks farm from Z cord to tp to
min.z: -500
#maximum amount of blocks farm from Z cord to tp to
max.z: 500
#Amount of time before the player will be allowed to use the command again
cooldown: 10 minutes
#Avoid spawning in lava, water and air
avoid: air or water block or lava block
#To add worlds it would look like
# worlds: "world" or "world_nether" or "world_the_end"
worlds: "world"
#Permission
permission: randomtp.use
#No permission message
PermMsg: &4You do not have permission to use this command!
#Can not execute command in this world message
NoWorldMsg: &4You can’t use this command in this world!
#Cooldown message
SpamMsg: &4Please do not spam this command!
NoMoveMsg: &4Please do not move until you get teleported!
Command /randomtp:
description: Teleports player to random location not in water
permission: {@permission}
permission message: {@PermMsg}
aliases: /rtp, /wild, /random
trigger:
if world is not {@worlds}:
send "{@NoWorldMsg}"
else:
if difference between {cooldowns::randomtp::%player%} and now < {@cooldown}:
send "{@SpamMsg}"
else:
send "{@NoMoveMsg}"
rtp(player)
function rtp(p: player):
delete {movewait.%{_p}%}
set {_loc::old} to {_p}'s location
continueRtpLOOP({_p}, {_loc::old})
function continueRtpLOOP(p: player, oldloc: location):
if {_p}'s location is {_oldloc}:
set {_loc::new} to location at random number between {@min.x} and {@max.x}, 0, random number between {@min.z} and {@max.z} in {_p}'s world
loop blocks above {_loc::new}:
if loop-block and block above loop-block are air:
if block under loop-block is not air or water or lava:
set {_loc::new} to location of loop-block
teleport {_p} to {_loc::new}
set {cooldowns::randomtp::%{_p}%} to now
if light level at {_p} <= 2:
set block at {_p} to torch
stop
stop
wait 2 ticks
continueRtpLOOP({_p}, {_oldloc})