-- Runs when player dies or leaves. If one player is left, fires the end round 

local function checkPlayerCount()	
	if #activePlayers == 1 then
		roundEnd:Fire()
	end
end

local function removeActivePlayer(player)
	for playerKey, whichPlayer in pairs(activePlayers) do
		if whichPlayer == player then
			table.remove(activePlayers, playerKey)
			-- REMINDER: Make sure status updates before the checkPlayerCount. If not, value changed will overwrite the Winner status text. 
			playersLeft.Value = #activePlayers
			checkPlayerCount()
			return
		end
	end
end

local function setPlayerCollisionGroup(player)
	local character = player.Character
	
	if not character then
		character = player.CharacterAdded:wait()
	end