To save a script as a text file:

Choose File > Save.

Choose a location to save your file.

In the Save dialog, choose text from the File Format pop-up menu.

Enter a name for the script (.applescript is the filename extension).

Choose one of the following line-ending options from the Line Endings pop-up menu:
UNIX (LF): A line feed character (ASCII character 10) is used to mark line endings.
WINDOWS (CRLF): Both a carriage return character and a line feed character are used to mark line endings.
MAC (CR): A carriage return character (ASCII character 13) is used to mark line endings.
Preserve Line Endings: Choosing this option saves the file with its existing line endings.

Click Save.