How to create a shadow function?

And how do I make it so that I play not for the spectator, but for the same player who passed for the first time?