This glitch happens when you put ascii numbers below 32, or any character that may appear as an empty box, into your code. When you switch sprites, all your code except a few blocks will appear to be deleted. To fix this, export the sprite, then import it, and the code should be back. There may be random new lists and variables, and the code may have changed. To avoid this, put the illegal character into a list and add an "item n of list" instead of the actual character.