What gamemode are you using?
Some gamemodes have an custom spectator system, that means you need to call the gamemodes function.
/E: As you see you call it under "PlayerSpawn", that means it only get's executed if he spawns and therefore he isn't marked as afk (if im right, i am not familar with how aafk works) .