President Barack Obama on Wednesday defended his administration's guidelines to schools advising them to allow transgender students to use the bathroom of their choice.

The president made his remarks during a town hall in Elkhart, Indiana moderated by PBS News Hour anchor Gwen Ifill.

Twelve states have joined in a lawsuit challenging the administration's directive. Kansas has said it will also sue the federal government but is uncertain as to whether it will file a separate suit.

(Related: Kansas to challenge Obama's transgender bathroom policy.)

Obama told the questioner that he believes transgender students are being treated unfairly.

“What happened and what continues to happen is you have transgender kids in schools. And they get bullied. And they get ostracized. And it's tough for them,” Obama said.

Obama said that school districts had asked the administration for guidance on the issue.

“And my answer is that we should deal with this issue the same way we'd want it dealt with if it was our child. And that is to try to create an environment of some dignity and kindness for these kids. And that's sort of the bottom line.”

“Now, I understand that people, you know, for religious beliefs or just general discomfort might disagree. And I'm not the one who's making a big issue of it. But if the school districts around the country ask me, 'What do you think we should do?' Then what we're going to do is tell them let's find a way that makes sure that these kids are not, you know, excluded and ostracized.”

Obama added that he believes the issue will be settled by the courts.