NEED SOME HELP!

Personally - I'd just rewrite this thing.

Yep. Separate the state change detection bit from the debouncing bit. They are two independent activities.

And, ditch the useless comments. Anyone can see that x++ increments a counter.