Gaining weight instead of loosing it

I'm gaining weight instead of losing it.

So I'm doing 20/4 if and I haven't been consuming carbs since I started ( 4 weeks now). I started IF coz of the long term health benefits and to loose the excess weight I have had on me for the longest. I started walking a lot more and I joined the gym 4 weeks ago. I go 3 sometimes 4 times a week. I lost 4kg in the first week and a half. Lost another after a week. But then my weight has gone up! 😣 And I have stayed consistent! Is there something I could do/change? + I am on a calorie deficit.