Hearts were broken earlier this year when Luke Perry, star of Beverly Hills 90210 and The CW's Riverdale, passed away at the age of just 52 from a stroke. The season 4 premiere of Riverdale, "In Memorian," was a tribute to Perry that also said goodbye to his character, Fred Andrews, with Perry's fellow 90210 actor Shannon Doherty appearing in a guest role.

Riverdale season 4 opens several months after the end of season 3, with the town preparing for July 4th celebrations. While at Pop's Chock'lit Shoppe with the gang, Archie gets a call from his dad's phone - but it's not Fred on the other end. Jughead, Betty, and Veronica gather around Archie as he collapses in shock from the news that his father is dead. After stopping to help a stranded driver with a flat tire, Fred was struck and killed by a hit-and-run driver. Later in the episode, when Archie goes to pick up his dad's truck from the side of the road, he meets the woman whom Fred was helping when he died (played by Doherty). She tells him that the car almost hit her, but Fred pushed her out of the way, sacrificing his own life.

Related: Riverdale Season 4 Trailer Includes Luke Perry Tribute

Though Archie's friends try to comfort him by saying that Fred died a hero's death, Archie is angered by the senselessness of it. When FP Jones calls with the news that the hit-and-run driver, George Augustine, has turned himself in but has since made bail, Archie looks up Augustine in the phone book and drives to his house. He angrily confronts the man, punching the wall next to his head, but George Augustine's teenage son rushes out and confesses that he was actually driving the car, which he'd taken without permission. Archie, thinking back to all the times he took Fred's truck without permission, is shaken by the encounter and thinks his father would have been ashamed of his actions. His friends reassure him that Fred loved him and was proud of him.

Using a hearse borrowed from Reggie, Archie drives Fred's body back from the funeral home in Cherry Creek to Riverdale. Outside of town he is stopped by FP, who says he wants to be part of bringing Fred home, and offers a police escort. As they drive back through town, they realize that Riverdale's planned Fourth of July parade has instead become a welcome home party, with the whole town gathered to hold signs expressing their love for Fred Andrews and his family.

At Fred's funeral, Archie gives a speech about how his father "helped build this town," and that he has left a legacy in the shape of all the places in the town that his construction team fixed up. Jughead writes Fred's obituary in The Riverdale Register, summing up his life by saying, "Fred left Riverdale better than when he found it." Fred's old group of high school friends - Alice, FP, Hiram, and Hermione - mourn his loss despite their disagreements over the years, and Hiram even pays for all of the funeral costs. For the very first time in the show, it seems that Hiram doesn't have an agenda when making this gesture.

Back at the Andrews household, Mary, Archie, and the gang gather to set off fireworks contributed by Cheryl Blossom. Towards the end of the episode there's a flashback to the season 2 episode, "A Night to Remember," in which Archie revealed to Fred that he'd returned a Pontiac Firebird gifted to him by Hiram Lodge, and decided instead to work on restoring the old jalopy in the garage. It was a tender bonding moment for father and son, marking the end of one of their fights. The end credits of "In Memoriam" open with a tribute "In Loving Memory" of Perry.

More: Riverdale Season 4 Cast & Character Guide

Riverdale airs Wednesdays at 9/8c on The CW.