Not only were Luke Perry and Ian Ziering co-stars on Beverly Hills, 90210, but they were also close friends. Ziering took to social media to share a heartwarming story about Perry just one day after his sudden death.

(Photo: Instagram / @ianziering)

In a throwback photo, Ziering and his pregnant wife, Erin Ludwig, pose together during a maternity photo shoot while Perry stands in front of them, holding wooden planks while apparently in the middle of a home project for Ziering.

"The day Erin and I were shooting maternity pictures, Luke decided I needed a fenced-in area to keep the baby safe in my backyard," Ziering wrote alongside the image shot circa 2011 with the hashtag, "RIP Luke Perry."

Ziering shares daughters Mia, 7, and Penna, 5, with Ludwig. The photo shoot Perry "interrupted" was before the couple welcomed Mia.

It wasn't the first tribute Ziering paid to Perry in the days since his death. The 54-year-old reflected on his friendship with the Riverdale actor on Instagram.

“Dearest Luke, I will forever bask in the loving memories we’ve shared over the last thirty years,” he captioned a photo of the duo embracing. “May your journey forward be enriched by the magnificent souls who have passed before you, just like you have done here for those you leave behind. God please give him a seat close to you, he deserves it.”

(Photo: Instagram/Ian Ziering)

Many of Perry's other 90210 co-stars have also mourned his loss on social media. Shannen Doherty, who played Perry's love interest, wrote, "I"m struggling with this loss and am having a hard time with my thoughts."

Randy Spelling, whose late father, Aaron Spelling, produced the show, wrote, "My thoughts and good wishes go out to his family. A good guy with a good heart. You will be greatly missed Luke."

Tori Spelling, who starred on the long-running series alongside Perry, said that she was "in utter shock and heartbroken" by the news.

"I’m saddened for his kids whom he adored beyond words. He was so proud of Jack and Sophie," she told people of the late father of two, who is survived by son Jack, 21, and daughter Sophie, 18, whom he had with ex-wife Rachel "Minnie" Sharp.

"Luke was one of the kindest and most humble human beings I've ever known," Spelling continued. "I'm grateful for the years of friendship we had. He truly was family to me, a protector and a brother. I'm so sorry for the loss that everyone is experiencing."

Perry died Monday morning, five days after suffering a "massive stroke" at his home. His publicist confirmed that he was surrounded by his children, fiancée, ex-wife and siblings at the time of his death.

“The family appreciates the outpouring of support and prayers that have been extended to Luke from around the world, and respectfully request privacy in this time of great mourning,” Monday's statement read. “No further details will be released at this time.”