This article pertains directly to the iPhone/iPad app. For a full article on how to restore your script from History click here.
When you're using either the Script app on your iPhone or iPad make sure to back out of your script when you are finished writing. If you stay in your script and close the app, your changes won't be getting synced, and then when you open up the script again in the app the newest in-Studio changes aren't going to show up and you will end up overwriting the the latest draft.
So, if you remember to click the back arrow in the top left corner of the script editor in your app, the sync wheel will turn and then stop, and then you will know you have successfully synced with the online Studio.
In case you did save over your latest draft, you can restore your script from the History of your script. Follow this link to the History help article.