you need a spirit level, make sure the posts are spot on, then each slat
you might have to plane a few slats to make it all work and don't be afraid to have the top stepping up each slat - like a stairs, that's how a slope is fenced
or you could have a smaller gap at the bottom and a larger gap at the top