This guy thought he had it all planned out until the clerk of the store showed his real gun and thwarted the perfect robbery.

According to WPXI-TV, 42-year-old James Hayes walked into a convenience store in Ambridge, Pennsylvania with a plastic BB gun and tried to rob the place.

Abdul Belaouni, the clerk of the store, recognized it was a plastic gun and reached under the counter to reveal his REAL gun.

Hayes realized he was screwed and tried to wrestle the gun out of Belaouni's hand, but he was much stronger than Hayes, so he took off.

As he was running away, Belaouni showed him who was really in charge and kicked him in the butt on his way out the door.

The police tracked Hayes down later that day and arrested him and charged him with attempted robbery.

Check out the surveillance video here.