Global variable not sticking

So the problem is in the code you didn't post.