Density functional theory (DFT) methods were used to study the atomic and electronic structures of methane molecules adsorbed on pristine, vacancy-defective, and transition-metal (TMs: Mn, Fe, Y, Mo, Ta, W)-doped Hf2CO2. The interaction distance between the methane molecules and original substrate was large, and the adsorption energy was small, suggesting that the a physisorption adsorption. After introducing O-vacancy, the adsorption of CH4 changed into chemisorption. Through the doping with TM dopants, the methane molecule adsorbed onto the Ta-doped Hf2CO2 exhibited the highest stability and the largest adsorption energy. In addition, the W-doped Hf2CO2 changed from being a semiconductor to being a conductor after the adsorption of methane molecules onto the material; this phenomenon suggests that the change can be used as a signal for sensors in detecting methane gas. These results are expected to provide new insights into the design of gas sensors based on MXenes materials.