I think there's a lot of potential in this system, but there should be some limits placed to prevent abuse and encourage the player to seek out stronger enemies. I'm not sure whether you (or anyone else, if you'd allow it) would be interested in improving this script, but I have a couple of ideas regardless.
1. A growth curve for each stat. For example, if a character's strength stat is between 1-19, it might take between 5 and 10 attacks to increase the stat. Between 20 and 39 it would be 10-20 attacks, 40-59 = 20-30, etc.
2. Added to that, the "hit counter" could be modified depending on how strong the enemy party is (by assigning hidden "ranks"). A group of Goblins at the start of the game would only raise the "stat count" by 1, while a party of endgame Dragons increase them by 10. So if your strength is 100 then you'd need to attack 50 or so times in a Goblin battle to increase strength, whereas against a group of Dragons you'd only need to attack 5 times for the same result.
Both of these would stop only the most persistent of players from maxing everything at the start of the game, as well as make it much easier to "level up" characters who may've been neglected until late in the game. Final Fantasy II actually uses a monster ranking system, although not in quite the same way.