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