Bloating can cause weight gain but yes the bloating is only temporary and will go away once the bloating goes away.
Bloating during your period can cause normal temporary weight gain as well and when the period is over and the bloating goes away then you'll lose the weight gain afterwards.
Excess water weight normally causes the bloating but there's no need to worry as it will go away.