Thanks for the reply.
I managed somehow to boot it up after booting the Macbook from a windows hard drive. I saw that it was working fine so it couldn't be the GPU, so turned it off and did a PRAM reset and a internet recovery. After fixing the HDD with the Mac's tools it booted up, but it took like 5 minutes. The programs were so slow to open up so I thought it was something wrong with the HDD. After opening up Safari I had a blue screen and it shutted down. I took away the HDD and did a full sector scan and it had a damaged sector. I thought it had both GPU and HDD problems so I bought a Samsung Evo 860 500GB and after hours of trying to get into recovery mode again I managed to make a clone to the SSD which took over 3 hours for 185GB. After that it took like 10 seconds to boot it up but after 2 minutes I had a weird blue screen (attached picture) so I thought I had to replace the logic board or I had to figure out to disable the dedicated GPU and use the integrated one. I attached a secondary monitor and made a 2 hours stress, then I used the Mac with the dedicated GPU for a couple of hours without getting artifacts or anything, maybe it was just a random driver crash.
Thanks for helping me out.