Legislation plays a crucial role in safeguarding the rights of individuals with mental health disorders, ensuring they have access to appropriate treatment and support.