Without a functioning pilot light, your water heater won’t be able to maintain internal temperatures which leads to cold water in the tank. Some reasons for a pilot light that won’t stay lit:
Dirty Pilot Tube – dirt and debris can collect in the pilot tube, causing the flow of gas to be blocked. As a result, the pilot doesn’t get enough fuel to stay lit. This is also a likely cause if the pilot won’t ignite at all.
Kink in the Flex Tube – The flex tube provides fuel via the gas controller. On occasion, the tube can become kinked, interrupting the flow of gas.
Obstruction in or Damage to the Thermocouple – the thermocouple picks up an electrical signal from the pilot light’s heat to determine whether the pilot is on. Interference with or damage to interferes with this signal, leading the thermocouple to believe the pilot has gone out. It then shuts off the gas supply as a safety precaution.
Main Control Valve – With all other options ruled out, a problem with the main valve control is almost certainly the culprit.