How would you make a toggleable character trail

I’m trying to make a trail which triggers when the player uses a time slow mechanic. I want it to be pretty much like the sandevistan trail in edgerunners but I have no idea how to do it

(https://64.media.tumblr.com/40a1425bfaf15783ea03633558369aae/e8a48f70478d2ea1-dd/s540x810/5f890f545d55da50c51c4ceb201dd29320fdd3e7.gif)

As shown I want it to take the previous frame of the player animation and put it where they used to be (if they haven’t moved location then behind the player sprite) and change the colour of the frame to form the rainbow like trail shown

This is for a 2D slide scrolling platformer