Simple Spectator system?

Hello guys. It’s been a while since I started to make a Spectator System for my gamemode. But It never works. So someone can send me a tutorial to teach me how to do a Spectator system?

Player:SpectateEntity

Player:Spectate

Player:UnSpectate

I tried to do this. But I’m having serious problem with spectate another player and spectate roaming. Can you help me?