In addition to @sorin's answer, the most likely cause for this error is that you do not have permission to save scripts.
By default only system is allowed the create new scripts.
The solution is to enable write access for yourself.
Open Finder
Go to folder: /Library
Right click on the Scripts folder
Get Info
expand v Sharing & Permissions:
Click on the 🔒 lock to allow changes.
Add + a user (either Administrator, or your own user account)
and give that user Read & Write permissions.
Finally,
Click on the (...)V and Apply to enclosed items...
You will now be able to save new scripts.
.scpt
files by hand when this is a compiled file format (contrary to.applescript
). Lri gives the right answer here.