When we try to remove a clothes suddenly, our body produces frictional heat, which produces a negative charge by transferring the molecules in the clothes, and a positive charge occurs in the body. This causes the clothes to stick to the body. And the transfer of that charge seems to have caused the lightning to appear in the clothes.