Making the code wait

is there a way to tell the code in a function to wait a few seconds before executing the next action? i want it to play the fade out transition before it loads the next movie