Help needed for ending a round

Hey guys, I have been trying to rewrite the core game loop in my game as there are bugs and I’ve found an issue and I’m confused and don’t know how to fix it. Any help would be greatly appreciated, thank you.

So the game is deciding that I am losing when I shouldn’t be. The way it works is as the start it adds the tag “WasInMenuThisRound” to your player if you hadn’t pressed start on the start screen yet and adds the tag “WasAfkThisRound” to your player if you had the afk option enabled. At the start of the round it also adds a tag into your character called “Alive” so if you die it disappears. It checks if you have any of these tags and decides accordingly. Here is the function:

function module.EndRound(map)
	map:Destroy() -- Destroy current map
	
	for i, player in pairs(game.Players:GetPlayers()) do
		if player.Character then
			if player.Character:FindFirstChild("Alive") and not player:FindFirstChild("WasInMenuThisRound") and not player:FindFirstChild("WasAfkThisRound") then
				
				player.leaderstats.Wins.Value = player.leaderstats.Wins.Value + 1
				player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + (100 * player.Boosters.CoinBoost.Value)
				player.Character.Alive:Destroy()
				winEvent:FireClient(player)
				
			elseif not player.Character:FindFirstChild("Alive") and not player:FindFirstChild("WasInMenuThisRound") and not player:FindFirstChild("WasAfkThisRound") then
				
				loseEvent:FireClient(player)
				
			elseif player:FindFirstChild("WasInMenuThisRound") then
				
				player.WasInMenuThisRound:Destroy()
				
			elseif player:FindFirstChild("WasAfkThisRound") then
				
				player.WasAfkThisRound:Destroy()
				
			end
			
		end
		
	end
	
end