Maulik Pancholy is best known for his acting roles in such shows as 30 Rock and Phineas and Ferb. He also served on the President’s Advisory Commission on Asian Americans and Pacific Islanders. Recently, Pancholy helped launched an anti-bullying campaign called Act to Change. His debut middle grade novel, The Best at It, which releases next month, stars 12-year-old Rahul Kapoor, who is beginning to think he might be gay and, as an Indian American who already feels “different,” that thought worries him quite a bit. When he is taunted by a school bully, he decides he must prove to himself and the world that he is the best at something. Though Rahul and his story are fictional, Pancholy shares in the book’s foreword that the character’s struggles mirror many of his own as a pre-teen. We spoke with Pancholy about writing, acting, and the life experiences that led to the idea for this book.

Tell us a little bit about yourself as a kid. What was it like growing up?

I was born in Dayton, Ohio. When I about two years old, we moved to Wabash, Ind., and lived there until I was about seven. Those years were magical—full of riding bikes in the neighborhood and leaving doors unlocked and walking to school. I eventually moved to Tampa, Fla., where I spent my middle and high school years. But even there, in a much bigger city than Wabash, I still had a sense of being different. At the time that I was growing up, no one was talking about being gay. That was a long time ago, but in a lot of smaller towns in America and in the Midwest, I think that’s probably still true and still a challenging situation for kids. It’s one of the reasons a small, Midwest town felt right for this book.

Your main character, Rahul, is extremely good at math. Did you enjoy school, and were you also a math whiz?

I was actually a very good student. I studied a lot and got good grades. I was also a Mathlete so math competitions were a big part of my junior high and high school experience. A teacher who I’m still friends with ran the math club, which was a big deal at our school. We traveled to international math competitions in other countries. For me, winning those competitions was a way to prove my self-worth, which then became a huge theme in the book.

You’ve talked in interviews about being an avid reader as a child. What kind of books did you read?

I had all these book sets: The Hobbit, The Black Stallion, even Little House on the Prairie. What I remember, though, is that while I related to those characters, I never saw any who looked like me. I don’t think I understood what that meant until I first started auditioning for television shows as an adult. I had a really hard time seeing myself in the roles, mostly because I never saw anyone on television who looked like me. I realized that, as a kid, I’d felt like I had to be somebody else if I wanted to emulate a character in a book. It’s exciting to be entering this literary world now because there is a lot of support for diverse storytelling. I think young people are actually hungry for it, too. We don’t live in a homogenous world. Kids want to see truth in the stories that they read.

When did you know that you wanted to write a book, and that it was going to be a book for kids?

As an actor, I had done a lot of animated series. I’d been around young people and got to see how much storytelling mattered to them and how influenced they were by the stories they saw on television. When I served on the White House commission under Obama, a large part of the work I did there was interacting with young people. It just felt like a natural fit, to be honest, to start writing a story for young people. For a while, it was sort of an extracurricular thing. Then we pitched the first 10,000 words and had multiple publishers bid on the story. Suddenly I was like, oh, my gosh, I really have to write this book.

How long did it take you to write?

It took me longer to write this book than I think it takes most authors. Right after I sold the story, I was hired to act in two back-to-back plays. That stretched out the process a little bit.

Did you have it all planned out in your head or did the story unfold as you wrote?

My original instinct for the book was to take a humorous perspective toward a lot of the issues that Rahul deals with, including his sexuality, his cultural identity, the anxiety, and the behaviors that go along with that anxiety. I credit my editor a great deal for pushing back on that, because as we delved into the story, it felt more honest to be truthful about those things and let them be emotional. I think we found a nice balance between having it be a funny story, but also exploring these topics in a deeper way.

Rahul struggles with obsessive-compulsive behaviors that he seems aware of and tries to hide from his family. Can you talk about why this became a part of his character?

This is something that’s really personal to me. I was careful in the book to not label it OCD because I know there’s a technical definition for it. But I myself have struggled with some checking behaviors that have gotten better as I’ve grown up. I remember there was a period when I was really young when I would do things like check the stove and the locks. I was very good at hiding it, though. The conversation that I’ve written in the book between Rahul and his dad isn’t a conversation I was able to have. My parents were amazing, but it was something we weren’t talking about. It was exciting to get to write something that might offer a path for a young person or a parent reading this story to think, “This is a conversation that can be had in a positive and loving way.” Also, even though Rahul is aware of these behaviors, he’s really confused by them. When his mom asks him why it embarrasses him that his Indian aunties came to school in saris, he doesn’t really know why—he just knows that feeling different feels uncomfortable.

Rahul has both a supportive best friend and family. Why was it important to have Rahul’s family be such an integral part of his journey?

I tried to find a balance between having him going on this journey by himself but also having support. There’s a moment at the end of the book where Rahul has to jump in the fray and stand up for himself. But I also know from my own experience there is fear and anxiety around coming out. I was actually met with so much love when I finally did, though it took me a lot longer than it took Rahul. I wanted to offer the possibility to young people that having the courage to be yourself can actually be met with a lot of love.

In this book, you address an important and relevant theme to many middle graders: accepting who you are. What would you say to a young reader who reads this but says, “He’s a famous actor. It’s not easy for someone like me.”

Yes, life turned out pretty well for me because I followed my passions and did the things I want to do. But I also want to share with kids that I’m not really that different from them. The struggles that I went through in middle school probably look a lot like their struggles. I hope this book will find its way into the hands of LGBT kids and Asian-American and South Asian American kids, but I also think there are a lot of universal themes in it, such as struggling with being different, trying to find your place in the world, and wanting to be accepted. Those were things that I dealt with as a middle schooler, and I hope I can relate to young people on that level and let them know that I get what they are going through.

If you read the “perfect” review of this book, what would it say?

These initial positive reviews have been more than I could have ever hoped for. What I love most, though, is that there is a sense that people really empathize with Rahul and understand what I intended to do with this story. As a writer, you put in all this work and you just hope that it’s going to land. The fact that people are really, truly getting it is as good as it gets.

Do you have any plans to write more books?

I do actually have an idea that I’m tinkering with. It’s a little too early to talk about, but I really loved the writing process. Being an actor doesn’t always fulfill me in terms of getting to tell the exact story that I want to tell. But when you write a book, you get to delve into so many different characters at once. That was a part of the process that I really loved. There was also this moment for me where the story started to tell me what it wanted to be. That process of discovering was really fulfilling. It made all those days when I was sitting at the computer and had no idea what to write worth it. So, yes, I would love to do this again.

The Best at It by Maulik Pancholy. HarperCollins, $16.99 Oct. 8 ISBN 978-0-06-286641-7