I don't really deal with PokeScript but as far as I can see, there shouldn't be anything wrong with it in-game.
Since that is the case, I'd put this error down to PokeScript being outdated and buggy - Switch to XSE if you would like the best scripting program.