So i just went to the setup wizard app and gave it contacts and phone permission and it finally worked.
This error generally comes with CM roms so this fix will work with CM based roms and might work with other ROMs also.
1) Flash ROM
2) Flash any gapps
If you get setup wizard error then continue the steps below and yes you need patience to do this because it will keep on popping up until you fix it. You need to keep on tapping and scroll down for a while.
3) When you see setup wizard error pull down notification drawer and open settings
4) Scroll down and tap "Apps"
5) Click on 3 dots at the top right corner.
6) Select show system apps
7) Scroll down until you see 2 Setup wizard.(If you have RESURRECTION REMIX ROM you will see only one)
There will be 2 setup wizard,one wil CM logo and other with android.
8) Select one with android logo.
9) Tap on force stop
10) Select ok
11) Scroll down and enable permissions(Contacts & Phone)
12) Now press the home button
You should now see your home screen
It just a simple fix.
Because of permissions that were needed by setup wizard were not fulfilled this error keeps on popping up.
Hope you guys now have fixed this and got you CM.