It doesn't work because you are treating the code as if only one of those events will run, but both run. If the sprite isn't visible, you make it visible. Then the very next event checks if it's visible, which it is, because you just made it visible, so makes it invisible again. You should never check one state then check the opposite. Use Else - it avoids this kind of error.