These days in majority of homes, you would find the standard tank-type water heaters. Their basic mechanism is convection. This means that cold water is supplied to the tank and is led to the bottom of the tank with the help of a dip tube. The denser cold water remains there and it is heated by the burner. Once the water heats up, it obviously rises, drawn off then by the discharge pipe for hot water. That was an overview of the mechanism of a gas water heater. Now, there is a gas valve attached to the supply pipe. If there is a problem with it, you would not get properly heated water. Here are some steps that explain how to go about with its replacement.
Cut the water and gas supply to the heater. You would find the water shut off above the water heater on the incoming water pipe. Likewise, the gas has to be shut off on the gas pipe, which has a connection with the gas control valve.
For draining the water from the heater, attach the garden hose to the valve of the drain. You would find it towards the bottom of the tank. Run or rather direct the other end of the hose where pouring hot water would not create any problem. Also, be careful while doing the same. Once you are done with that, open the drain valve and loosen one of the flex connections located on top of the tank for breaking the vacuum.
After the water drains out of the tank, disconnect the gas control valve. But before that you would need to disconnect the gas flex hose. The next to be disconnected are the 3 tubes entering the gas valve from the bottom. These are the pilot tube, burner tube, and the thermocouple, from left to right respectively.
At the spot where each of the above mentioned tubes enter the gas valve, there would be nuts, so loosen them. Then, pull down on the tubes for detaching them from the valve. Now, remove the gas valve from the tank, which will be made easy by a pipe wrench or a pair of large channel locks. It would help you unscrew the valve from the tank.
At this point, the valve has been detached from the tank. The task at hand is to determine the length of the shank, which is the threaded nipple coming out of the back of the valve, into the tank. Let the shank that is to be replaced, be of the same length as the original one. This holds true for the 3 tubes - pilot tube, burner tube, and the thermocouple.
Replace the valve and just as the dismantling or unwinding steps were done, do a rewind of those steps, ending at reinstating the water supply as well as gas supply. However, do not forget to attach the teflon tape or pipe dope, or both to threads of the shanks for preventing leaks.
Knowing the aforementioned steps, might prove beneficial to carry out this task. However, working with gas could be dangerous, if you are not certain about the way it is done. If you understand and follow the safety rules and precautions and are sure about the right method, then only go ahead with the same or call someone for help. If you go to a professional, the cost would be definitely more than what it takes to repair it at home.