Yes. The engine behaves differently when the PC is swimming, including the return value of GetPos.
On ground, the z position is at the feet level (where the PC stands). When swimming, the Z position retuned by GetPos seems to switch to something around shoulder level, but SetPos is not adjusted the same way, so it will have the effect you mention.
If you walk slowly into the water, the Z position drops accordingly until the PC starts swimming. At this point the Z instantly goes from about -100 to -5.
The actual difference is 105.29
Using your example, this code would compensate that effect
if playerref.isswimming set zplayer to playerref.GetPos z -105.29else set zplayer to playerref.GetPos zendifplayerref.SetPos Z zplayer