Actor and “30 Rock” alum Maulik Pancholy keenly remembers that being a middle school student can be tough.

“When I was growing up, I didn’t know a single person who identified as anything but straight,” Pancholy, who is openly gay, said. “There were just no role models, no one who was out.”

The knowledge that those years are particularly challenging for kids who feel different — whether it is because of their sexuality, race or religion — inspired Pancholy to write his debut novel “The Best at It,” which will be released Oct. 8 by Balzar and Bray.

While researching the book, Pancholy read lots of novels intended for middle school-age kids and also talked to educators about what life is like for preteens today. He was surprised when many said that books that addressed issues such as sexuality and mental health were relatively rare.

“I think kids are pretty sophisticated when it comes to diversity and sexuality because they are surrounded by it in media in a way that we weren’t,” Pancholy, 45, said.

“The Best at It” tells the story of Rahul Kapoor, a middle school student in a small town in Indiana who loves hanging out with his best friend Chelsea and listening to his grandfather Bhai’s stories. But as Rahul begins to get ready for the start of seventh grade, he finds himself struggling with anxiety and the taunts of the neighborhood bully. He is also coming to terms with the fact that he has a crush on a popular football player.

Maulik Pancholy Luke Fontana

The character of Bhai was in many ways based on Pancholy’s own grandparents. “We never had conversations around sexuality or anxiety or those kinds of things, but I had the most amazing conversations with him as a kid,” Pancholy said of his grandfather, who along with his grandmother, moved to the United States when the actor was in his teens. “A lot of what I put in the book were models for conversations I wish grandparents and parents would have with their kids but don’t always know how to have.”

The interactions between Rahul and the class bully Brent Mason were heavily influenced by the research Pancholy did while a member of the President's Advisory Commission on Asian Americans and Pacific Islanders during the Obama administration, which extensively focused on how bullying in schools uniquely affects young Asian Americans and Pacific Islanders. That work also inspired Pancholy in 2016 to co-found the anti-bullying campaign Act to Change, which builds on the work the commission began.

“There are anti-bullying campaigns out there who are doing amazing work and we certainly look up to them, but a lot of them aren’t addressing what Asian American kids are going through around being bullied,” Pancholy said, adding that young community members are often singled out due to their religion, immigration status and race.

But in addition to the community experiencing a disproportionate amount of bullying, the commission also found that many parents and guardians were unsure about how to address the issue, with many playing it down. “There seemed to be a sense of just ‘put your head down and do your work and don’t worry about what other people are saying.’ But that definitely doesn’t work,’” Pancholy said.

Pancholy hopes that children who have anxiety will also be able to see in the character of Rahul someone who reflects their experiences. Throughout the book, Rahul becomes worried about things like the stove accidentally being left on or the danger of unlocked doors in the middle of the night.

“I dealt with anxiety and I had it as a kid for sure,” Pancholy said. “I was really good at hiding it but I also think that my parents were somewhat aware that I was worried about things.”

One of his favorite scenes occurs when Rahul’s father begins to notice how anxious Rahul is about the placement of the bed in his room. “It was certainly one of those conversations that I didn’t even know I needed to have as a kid,” Pancholy said. “But looking back it was like, ‘Oh wow, wouldn't it have been so great to say these things.’”

But while he hopes that “The Best at It” allows middle school students to see their experiences on the page, most of all he wishes for readers to experience a good story.

“I didn’t set out to write the book as a message or think, ‘Oh, these are all the things I want to include,’” he said. “There is a lot of joy in it, but there is also a lot of truth in it about how it is not always easy.”