Well, the basic answer is to just design your code in a way that you aren't using SPOFS, etc. on deleted sprites.
The simplest just-make-it-work solution would be to wrap those commands in an IF SPUSED(O) THEN. However, you may want to look into SPFUNC when it comes to designing more complex programs.
Deleting a sprite
Spoiler
Let's say you have a game that uses touch screen. there is a strawberry and a plate, if you grab the strawberry, it'll spawn another strawberry with which you can move however you want, if you let it go, it will go back to the strawberry you took it from and then disappears, but if the strawberry touches the plate and you let it go, it will go to the middle of the plate. So now let's talk about the problem... To spawn another strawberry i use code that looks somehow like this:O=SPSET(0)That means when you spawn a strawberry the management number goes up. I already made so O goes to 0 after goijg back to the base strawberry, but that didn't change anything at all. Everytime i spawn another one, the management number is 1 time bigger than before, it basically skips the number that is already used. When i try SPCLRing the O it finds many errors because i use O in SPOFS,SPANIM etc. So what should i do to fix it? I'll try to tell you as much information about my program as you need to know