To answer your first question, that's finding the actors partymember number.
To the second part, the problem isn't the variables, it's that the event just stops running as soon as you finish the stat distribution. I tested this by putting a text saying "Test" directly below the stat distribution script call. It didn't show up. However I don't think it's a problem with the script because, as I've said before, if the event is run because of a level up it all runs fine. It's only if called through a common event call that there's a problem.