Riku gave in to the darkness so he could get Kairi back. when he found out Sora was the keyblade master and had replaced him with Donald and Goofy (or so he thought) he was jealous of the keyblade ande angry at Sora with Donald and Goofy. then Maleficent and Ansem used this weakness of his to give in completely to the darkness.