Try using something like Unnamed Trainer Editor instead and see what happens. I heavily doubt this has anything to do with your script at all and you forgot to repoint your trainer data or something. Your script only calls up the dialog and what you've added in the editor in this case, and initiates the battle. Therefore your script would not effect the editor in any way as it edits the part that isn't in the script, and it doesn't even read where the script is in the first place. Or A-Trainer screwed up and corrupted the trainer, that happens rarely.
UTE tells you when you need to repoint anyway, which is nice and resolves about 99% of problems with trainer editing.