Gold isn’t valued in dollars. You can sell gold for any currency.
Oil is primarily transacted with dollars because it’s the worlds reserve currency. But if that were to change to whatever, you can still sell your oil and gold for whatever the new dominant currency is. Meanwhile your dollar is (presumably in this case) worth way less in terms of buying power than when you first bought it.