If I bought a game from psn say like gta. Then sold my ps4 and got a new one would I be able to download said game on my new system
Yes, if you log into the same PSN account you purchased the game with on your new PS4, you can re-download any purchases you previously made on that account. Digital purchases are only bound to accounts and not to the physical hardware. This also means, that when you remove your PSN account from the console before you sell it, the new owner won't have access to any of the games.
Also, save files for games that aren't online multiplayer are stored on the console, so if you want to continue your game progress on the new console, you need to back them up either online with PS Plus cloud storage or on a USB stick.