Whenever you need to do something after a delay, you need to use schedule().
Schedule causes a specific function to be run later on. the format is schedule(<delay>, 0, <function>, <0 or more arguments for <function>>);
The 0 (second parameter) has a purpose, but it is not important. The delay is the number of thousandths of a second to wait (1000 means one second). <function> is the name of the function, as a string.
So, if you wanted to call foo() in two seconds, you could use
schedule(2000, 0, "foo");
while if you wanted to call bar(42, 7, "hi, mom") five and a half seconds later, you could use
schedule(5500, 0, "bar", 42, 7, "hi, mom");
The function name may not need quotes, but that seems to be more of a feature of the engine than of schedule() itself, as echo(hi); does the same thing as echo("hi");. I, personally, wouldn't rely on it without specifically reading it as a feature of the language, though, just in case it causes some subtly different, and unexpected, result.
Edit: Just to be clear, when you use schedule(), the function that called schedule() continues immediately; it doesn't wait until the scheduled function finished. Also, schedule() returns a number that can be given to cancel() to stop the scheduled function from running (but only if it hasn't run yet).
Edit again: Using schedule(), you can create features that aren't otherwise provided, such as repeating a function every N seconds (have the function schedule itself), or stopping in the middle of a function and continuing after a delay (though that tends to require passing a lot of parameters. Using a ScriptObject can help here, either simply as a place to store somewhat more persistant data (creating a new ScripObject and storing data that would otherwise need to be passed as parameters on it, then just passing the ScriptObject), or in a more object-oriented way, by calling the functions on an instance of the ScriptObject itself).