That depends on how they’re incorporated into your diet. If they contribute to you being in a calorie surplus then they can help you gain weight (with research showing that they can also help maintain a desirable body composition whilst gaining weight).
If they contribute to you being in a low calorie then they help you in weight loss (research showing they can manage body composition).