I make spectate button and player can’t respawn after spectate?

I make spectate button and the players can’t respawn again after spectate , how can I fix it ?