teleport player 15 blocks ahead and also not be in the ground

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

Aug 8, 2025
4
0
1
im trying to make a skript (well a twist but whatever) where you can teleport 15 blocks ahead, but it keeps putting the player in the ground, or crashing the server (might be on the cooldown side idk)
here's the code:

if player's off hand item is a nether star named "&7Star of &5&lEnder":
if player has player's off hand item on cooldown:
send action bar "&c&lCOOLDOWN!!!"
else:
set item cooldown of player's off hand item for player to 20 seconds
set {_loc} to location 15 infront of player
while block at {_loc} is air:
set {_t} to 0
if {_t} > 1:
play sound "entity.firework_rocket.large_blast" with volume 1 and pitch 0.5 for all players at {_loc}
set {_t} to 0
wait 1 tick
teleport player to {_loc}
 
Using the Skript-Reflect addon, I managed to get this.


Code:
import:
    org.bukkit.Location

command /test:
    trigger:
        if executor is a player:
            set {_p} to executor

            set {_dir} to {_p}.getLocation().getDirection()
            set {_dir} to new Location({_p}.getWorld(), {_dir}.getX(), 0, {_dir}.getZ()).toVector().normalize()
            set {_target} to {_p}.getLocation().add({_dir}.multiply(15))

            set {_world} to {_p}.getWorld()
            set {_x} to {_target}.getBlockX()
            set {_z} to {_target}.getBlockZ()

            set {_y} to {_world}.getHighestBlockYAt({_x}, {_z})

            set {_tpLoc} to new Location({_world}, {_x} + 0.5, {_y} + 1, {_z} + 0.5)
            {_p}.teleport({_tpLoc})
 
import: org.bukkit.Location command /test: trigger: if executor is a player: set {_p} to executor set {_dir} to {_p}.getLocation().getDirection() set {_dir} to new Location({_p}.getWorld(), {_dir}.getX(), 0, {_dir}.getZ()).toVector().normalize() set {_target} to {_p}.getLocation().add({_dir}.multiply(15)) set {_world} to {_p}.getWorld() set {_x} to {_target}.getBlockX() set {_z} to {_target}.getBlockZ() set {_y} to {_world}.getHighestBlockYAt({_x}, {_z}) set {_tpLoc} to new Location({_world}, {_x} + 0.5, {_y} + 1, {_z} + 0.5) {_p}.teleport({_tpLoc})
hey i dont know if its just my server bugging but whenever i put this in and reload the skript file the test command does not appear
 

Attachments

  • stupidni.png
    stupidni.png
    55 KB · Views: 112
hey i dont know if its just my server bugging but whenever i put this in and reload the skript file the test command does not appear
check if you have the same command somewhere else; if so, then try changing the command.
And this code doesnt run without Skript-Reflect, it shouldn't break it