What's the best way to spectate players that are only in a round?

So, I made a simple spectate system that would spectate all players. But I want to make it so I can spectate players that are only in a round. I was thinking to make a loop that gets all players and adds a value to them. I tried using a module to check if the player is in the round or not. Are there any better ideas for this?

You can add a bool value inside the player instance “isPlaying” that sets to true when the round starts and sets to false whenever the player dies or whenever the round ends.

You can add an if condition that checks that bool value, if it’s set to true then you can spectate that specific player. It really depends on how you want to do it but since I don’t know how your system works this is my idea.

My system works with modules. So this is the best suggestion? If so thanks.

I usually use tables indicating active players. Whenever a player dies in the round or leaves the game I update the table and notify the client of the change. If they are actively spectating a player that has been removed, it goes to the next indexed player in the table.

Sorry for the long reply, could you show a quick example of how it might look like? I was trying to do what you said earlier but I was having trouble.