I've owned a Whirlpool Duet gas dryer model WGD88HEAW2 for 5 years. Recently, it started rattling only when the gas valve is closed while the dryer is operating. The rattle immediately quits when the gas valve opens and it is heating. The moment the valve closes, the rattle comes back. This rattle sounds like it is coming from the back right side of the dryer.
Everything else about the dryer seems to work fine. The drum rotates and clothes get dry.
At first, I thought it was the metal gas pipe vibrating against the back of the dryer. I haven't tried to take the top off to get a visual of what is going on.
The rattle is quite noticeable. It is not as loud as the "click" when the gas valve opens. It is like maybe something is rubbing against a roller or a gear? Sort of like how a baseball card flaps against a moving bicycle wheel when pinned to the spokes.