You run this after your time value reaches zero, so it will only fire for players who join the game after this point. You may want to perform any logic on existing players who were in the game during the countdown by looping through game.Players:GetPlayers() too.
As a side note, if you enclose your code in three backticks at the start and end (```) it will keep the tab spacing and format it in monospace to make it easier to read.
what my script does is there are enemies in a tower defense game and and i want make a collision group between them so it doesn’t matter if i do it after or before the time reaches zero the timer is just a countdown for the enemies to spawn and I can’t because the game.Players.PlayersAdded function is not working
the playeradded function will start looking for players AFTER the timer loop has finished. So it will only detecct new players after that code has fully completed running