How to fix "Failed to obtain IP address" while connecting to WiFi?

A

AC Question

I just had my phone (Samsung S7 Edge) a week ago and it connected just fine in our WiFi but yesterday (6 days after the purchase) it stopped connecting. There's an ongoing message that said "Failed to obtain IP address". Other devices connected just fine but mine doesn't. I've tried to change the IP setting to Static, it connects but I'm not able to use the internet, I've changed it back to DHCP and it automatically disconnect and the same message kept popping up. I've Factory Reset my phone and I'm still not able to connect to the WiFi. It still says "Failed to obtain IP address".

Please help.