You need to reset the "count" objective for all players after executing the test in your function (like I did). Otherwise, it won't work properly if there are 2 or more players on the server.
I used the @r selector since that will probably be the least laggy, but I think it's fairly negligible. The idea is that it stores the "count" objective in a random player to allow it to be tested directly through a selector (and thus the "if" parameter in /function). Then, after that has been tested, the score needs to be reset for all players for the next time it is used.