#tag
tag @s[tag=spectator] add stopspectating
tag @s[tag=!spectator] add spectator
tag @s[tag=stopspectating] remove spectator
tag @s remove stopspectating


#tellraw
tellraw @s[tag=spectator] {"rawtext": [{"text": "§7You're a spectator!"}]}
tellraw @s[tag=!spectator] {"rawtext": [{"text": "§7You're no longer a spectator!"}]}


titleraw @s [tag=spectator] actionbar {"rawtext": [{"text": "§7You're a spectator!"}]}
titleraw @s [tag=!spectator] actionbar {"rawtext": [{"text": "§7You're no longer a spectator!"}]}

#sound
playsound random.click @s