What "type" of global is x? Short, long float? Did you make sure it's not a constant?
I have come across seemingly crazy behavior with the CK/Papyrus (and I'm not new to coding) and many times I really thought something was a bug. Most of the time though, I found the problem was between the keyboard and the chair. Fortunately, I'm stubborn and I could usually track down the problem and most of the time, it actually made sense. I have never found random craziness with Papyrus though, nothing like the issues you have been experiencing. I'm not saying there aren't any bugs, just usually it ended up making sense.
It's a non-constant float.
It dawned on me that all this scripting weirdness only began when I started using the onplayerbowshot event. So I tried this code instead to see what would happen:
scriptname perkyperk extends perkglobalvariable property x autofloat fevent oninit()registerforanimationevent(game.getplayer(), "BowRelease")endeventevent onanimationevent... f = game.getplayer().getpositionx() debug.notification("f: " + f) x.setvalue(f) debug.notification("x: " + x.getvalue())endevent
Lo and behold, everything worked as expected. So it's the onplayerbowshot event that is doing funky things, but why? How can an event change the language's basic functionality? And are there more such events that cause weird side-effects?