How would I make a replay system in my FPS game?

How would I make a replay system in my first person shooter game? And example of what I’m trying to do is Frontlines; when the player dies they see the pov of the person killing them. I have tried a few things already, but none of them worked very well, and were inefficient and unoptimized.