If there are scripts in Google Sheets, will it be lost when the file is encrypted and decrypted?

Yes. If there are scripts in Google Sheets, it will be lost when the file is encrypted and decrypted by a user. This is a Google limitation.