Teleport delay

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

Buddha

Member
Apr 22, 2017
20
0
0
26
Hi, I've created a script to return to spawn whenever a player executes /spawn, however it doesn't work - whenever a player executes /spawn they get send the message, but instantly get sent teleport cancelled also.
Code:
command /spawn [<text>]:
 trigger:
  if arg-1 is not set:
   if world is "spawn":
    if {_zcoord} is not set:
     set {_xcoord} to x-coords of player
     set {_zcoord} to z-coords of player
     send "Teleporting. Stay still for five seconds!"
     loop 25 times:
      set {_x-check} to x-coords of player
      set {_z-check} to z-coords of player
      if {_x-check} isn't {_xcoord}:
       send "cancelled"
       delete {_zcoord}
       delete {_xcoord}
       delete {_z-check}
       delete {_x-check}
       stop
      if {_z-check} isn't {_zcoord}:
       send "cancelled"
       delete {_zcoord}
       delete {_xcoord}
       delete {_z-check}
       delete {_x-check}
       stop
      wait 4 ticks
     message "&7Teleported to spawn" to player
     delete {_zcoord}
     delete {_xcoord}
     delete {_z-check}
     delete {_x-check}
     set {_spawnx} to yaml value "X-Coord" from file "plugins/Spawn/Spawn.yml"
     set {_spawny} to yaml value "Y-Coord" from file "plugins/Spawn/Spawn.yml"
     set {_spawnz} to yaml value "Z-Coord" from file "plugins/Spawn/Spawn.yml"
     teleport player to location at {_spawnx} , {_spawny} , {_spawnz} in world "spawn"
     stop
    else:
     stop
     send "You are already telporting!"
 
Status
Not open for further replies.