-- not code

local PurplePlayers = script.Parent.PurplePlayers
local OrangePlayers = script.Parent.OrangePlayers
function newgame()
	
	
	
	matchStarted = true
	
	wait(3)
	
	for i, player in pairs(game.Teams["Orange Team"]:GetPlayers()) do
	player.Character:MoveTo(game.Workspace.OrangeTeleport.CFrame.p)
	end
	
	for i, player in pairs(game.Teams["Purple Team"]:GetPlayers()) do
		player.Character:MoveTo(game.Workspace.PurpleTeleport.CFrame.p)
	end
	
	-- clear dodgebool
	game.Workspace.DodgeBalls:ClearAllChildren()
	
	--redo
	for i, ballSpawn in ipairs(game.Workspace.DodgeBallSpawns:GetChildren()) do
		local newBall = game.Workspace.DogeBall:Clone()
		newBall.Parent = game.Workspace.DodgeBalls
		newBall.Handle.CFrame = ballSpawn.CFrame
	end	
	
	PurplePlayers.Value = table.getn(game.Teams['Orange Team']:GetPlayers())
	OrangePlayers.Value = table.getn(game.Teams['Purple Team']:GetPlayers())
	
	for i, sparkler in ipairs(game.Workspace.Sparklers:GetChildren()) do
		sparkler.Sparkles.Enabled = false
	end
	
end
while true do
	
	if matchStarted then
		
		if PurplePlayers.Value <= 0 then
			
			for i, sparkler in ipairs(game.Workspace.Sparklers:GetChildren()) do
				sparkler.Sparkles.Enabled = true
				sparkler.Sparkles.SparkleColor = Color3.fromRGB(255, 162, 0)
			end
			
			matchStarted = false
			
			wait(3)
		elseif OrangePlayers.Value <= 0 then
			for i, sparkler in ipairs(game.Workspace.Sparklers:GetChildren()) do
				sparkler.Sparkles.Enabled = true
				sparkler.Sparkles.SparkleColor = Color3.fromRGB(138, 0, 126)
			end
			
			
			--redo
			--for i, ballSpawn in ipairs(game.Workspace.DodgeBallSpawns:GetChildren()) do
			--	local newBall = game.Workspace.DogeBall:Clone()
			--	newBall.Parent = game.Workspace.DodgeBalls
			--	newBall.Handle.CFrame = ballSpawn.CFrame
			--end	
			
			
			matchStarted = false
			
			wait(3)
		 
		end
		
	else
		
		local purplePlayers = table.getn(game.Teams["Purple Team"]:GetPlayers())
		local orangePlayers = table.getn(game.Teams["Orange Team"]:GetPlayers())
		
	
			if purplePlayers > 0 and orangePlayers > 0 then
				
			newgame()
			
			end
			
		
	end
	
	wait(0.5)
	
end	
