British actor Sir Ian McKellen is speaking out about his life and sexuality in an effort to help prevent schoolyard anti-gay bullying.

In visits to UK schools arranged through gay rights group Stonewall's Education Champions Programme, the star of The Lord of the Rings and X-Men is reaching out to troubled gay teens.

“Until I visited secondary schools recently, I hadn't realized how much anti-gay bullying goes on, throughout the education system,” the actor told the BBC.

The 71-year-old McKellen is speaking to teens about his own decision to come out gay and the challenges faced by young people struggling with their sexuality.

“By talking frankly about my own life as a gay man and listening to the concerns of staff and students, parents and governors, I hope the visits arranged by Stonewall may make a difference in the classroom and the playground.”

“I also hope it will give confidence to gay students about their lives in the future,” he added.

McKellen has previously argued that being openly gay is a matter of happiness.