Rex will die by Cody for High treason against the republic.
In one of the seasons you will see ;p
Their will be an episode where the clowns will face for the first time order 66.
Rex can't accept that, so he will try together with Commander Cody to tell the jedi.
After all in the end, Cody Betrayed Rex for treason and kills rex.
End fo story