scoreboard players set @e[name=SpecCounterPermanent,type=armor_stand] SpecInitReset 0
execute @a[tag=Spectator] ~ ~ ~ scoreboard players add @e[name=SpecCounterPermanent,type=armor_stand] SpecInitReset 1
execute @e[name=SpecCounterPermanent,type=armor_stand,score_SpecInitReset=1] ~ ~ ~ execute @e[name=FunctionRunner,type=armor_stand,tag=NoPlayerLeft] ~ ~ ~ execute @a[score_GoBackToLobby_min=1,score_GoBackToLobby=1] ~ ~ ~ function main:reset/manualreset
execute @e[name=SpecCounterPermanent,type=armor_stand,score_SpecInitReset=1] ~ ~ ~ execute @e[name=FunctionRunner,type=armor_stand,tag=NoPlayerLeft] ~ ~ ~ scoreboard players reset @a[score_GoBackToLobby_min=1,score_GoBackToLobby=1] GoBackToLobby
scoreboard players reset @a[score_GoBackToLobby_min=1,score_GoBackToLobby=1] AFKTimer
scoreboard players tag @a[score_GoBackToLobby_min=1,score_GoBackToLobby=1] remove Spectator
scoreboard players tag @a[score_GoBackToLobby_min=1,score_GoBackToLobby=1] add Lobby
function main:lobby/lobby/teams if @a[score_GoBackToLobby_min=1,score_GoBackToLobby=1]
gamemode 2 @a[score_GoBackToLobby_min=1,score_GoBackToLobby=1]
spreadplayers 500 500 0 5 false @a[score_GoBackToLobby_min=1,score_GoBackToLobby=1]
execute @a[score_GoBackToLobby_min=1,score_GoBackToLobby=1] ~ ~ ~ playsound minecraft:block.stone_button.click_off master @s
execute @a[score_GoBackToLobby_min=1,score_GoBackToLobby=1] ~ ~ ~ trigger SpecClickReset set 1
scoreboard players reset @a[score_GoBackToLobby_min=1,score_GoBackToLobby=1] GoBackToLobby