NAIROBI, Kenya — At least four people were dead and 29 injured after a six-story residential building collapsed in the Kenyan capital on Friday after weeks of heavy rains, a government official said.

Rescuers were still searching for survivors as the night wore on, said the official, Wilson Njenga, the Nairobi regional commissioner.

It wasn’t immediately clear what caused the collapse of the building. Kenya has been the site of several disastrous building collapses in recent years, leading commentators to blame the government for failing to enforce regulations and conduct inspections.

But heavy downpours might also have played a role in the collapse on Friday. The annual “short rains” in Kenya which usually last from October to December, have been exceptionally heavy this year.