Error with pokemon battle

Basically what happens is whenever a battle ends i get my exp for my pokemon the pokemon levels and then the game crashes or the pokemon doesnt level and the game crashes. right after the exp/level sequence/ stat additions the game hits somethign that crashes it. and this is happening on the most recent version