Thank you for all of the replies, I got it working. I derped out for a couple of days to suddenly realize that y is up and down and put in the wrong parameters for math.atan2.
so instead of this Math.atan2( directionY , directionX) which is what I used before, I did this to fix it Math.atan2( directionX, directionZ )