What is the best to make a score system in an endless mobile game

the game is simple and I have already tried to make a score system in the game mode but I always get an infinite loop error.
is there a way to make a score system like subway surf that counts continuously ?