Press the flag. Shift-click and double click, I think it helps. No matter what the song eventually gets off tempo, so just click the flag to restart the project. If you want to change the tempo, just press "see inside" and change the value of the "set tempo to" block in both sprites.
I just put a melody I played on a piano into scratch.