From the Super Mario Wiki
A Sad Rex is an enemy found on Vibe Island in the game Super Princess Peach. Sad Rexes are Rexes that have been affected by the Vibe Scepter. Sad Rexes, like Sad Goombas, are simply sad Rexes that will simply sit in one location and weep. However, when Princess Peach approached one, the depressed dinosaur charges at her. Ironically, they are found mostly at Fury Volcano.
According to the game's Glossary, the Sad Rex "gets sad and attacks when it sees an enemy."