Trying to put a delay on /spawn command

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

Bread

Member
Aug 30, 2022
1
0
1
24
Hello, I am trying to put a delay on my /spawn command and when the player moves it will cancel the event

Code:
#! Script Version 2.6.3:
#!Minecraft Version: 1.17.1
#! this part is fine
command /setspawn:
    permission: op
    trigger:
        set {spawn} to location of player
        send "[&c&lBread&r] &bSpawn set to %{spawn}%" to player
        
#! this part needs help

command /spawn:
    trigger:
        send "[&c&lBread&r] &bTeleporting you to &aspawn &bin 3 seconds" to player
        wait "%{3}% seconds" parsed as timespan
        if player moves
            end event
            send "[&c&lBread&r] &bYou Moved!"
        teleport player to {spawn}

I am aware that the bottom half of this is very wrong.
 
You could do something like this

Code:
command /spawn:
    trigger:
        set {_} to player's location
        send "[&c&lBread&r] &bTeleporting you to &aspawn &bin 3 seconds"
        loop 3 times:
            wait 1 second
            if player's location is not {_}:
                send "[&c&lBread&r] &bYou Moved!"
                stop
        teleport player to {spawn}

This worked for me
 
Status
Not open for further replies.