In this case the #applybonus macro will not work in this case. Its designed to apply a "bonus" and does not work with penalties. In addition its made to only add the "highest" bonus to the field. Meaning if you had to Things trying to give a +2 and +3 bonus you want to end with only the +3 bonus. But penalties in Pathfinder always stack so we don't want that logic either.
If what you posted is your exact script then part of the issue is that you didn't change the second skill to be -2 diplomacy:
Code:
hero.child[skStealth].field[PenTrait].value = hero.child[skStealth].field[PenTrait].value - 2
hero.child[skDiplo].field[PenTrait].value = hero.child[skStealth].field[PenTrait].value - 2
We don't have a specific racial penalty but since all penalties stack in Pathfinder its easier to just use the Penalty field. You can also shorten your script logic using the += (plus equal) feature:
Code:
hero.child[skStealth].field[Penalty].value += -2
hero.child[skDiplo].field[Penalty].value += -2