!PenZ is a little different from !PenX and !PenY in that it is impossible not to change !PenZ when the pen goes up. In other words, !PenDown and !PenZ are confounded with one another.
One possible solution is to use !PenButton1 to decide when to hold the current value, for example:
!PenButton1 trackAndHold: !PenZ
You could, in fact, track and hold all three values (X, Y, Z) whenever you press the PenButton1.