In the movie, Ms. Waligwa played Gloria, a friend of the protagonist, Phiona Mutesi, who was played by Madina Nalwanga.

Phiona becomes a chess whiz with help from Gloria and under the tutelage of Robert Katende, played by Mr. Oyewolo.

The film was directed by Mira Nair and starred Ms. Nyong’o, an Oscar winner for “12 Years a Slave,” as Phiona’s mother.

“She played Gloria with such vibrancy,” Ms. Nyong’o said on Instagram. “In her real life she had the enormous challenge of battling brain cancer. My thoughts and prayers are with her family and community as they come to terms with having to say goodbye so soon.”

“Queen of Katwe” was the film debut of both Ms. Waligwa and Ms. Nalwanga.

“We mourn the loss of our beautiful Nikita Pearl Waligwa,” Mr. Oyewolo wrote on Instagram. “She was a ball of light in @queenofkatwemovie and in life. Her battle with a brain tumor was humbling to witness. Her light will live on.”