local C=script.Parent.PurplePlayers local c=script.Parent.OrangePlayers function newgame()matchStarted=true wait(3)for C,c in pairs(game.Teams["\079\114\097\110\103\101 \084\101\097\109"]:GetPlayers())do c.Character:MoveTo(game.Workspace.OrangeTeleport.CFrame.p)end for C,c in pairs(game.Teams["\080\117\114\112\108\101 \084\101\097\109"]:GetPlayers())do c.Character:MoveTo(game.Workspace.PurpleTeleport.CFrame.p)end game.Workspace.DodgeBalls:ClearAllChildren()for C,c in ipairs(game.Workspace.DodgeBallSpawns:GetChildren())do local r=game.Workspace.DogeBall:Clone()r.Parent=game.Workspace.DodgeBalls r.Handle.CFrame=c.CFrame end C.Value=table.getn(game.Teams["\079\114\097\110\103\101 \084\101\097\109"]:GetPlayers())c.Value=table.getn(game.Teams["\080\117\114\112\108\101 \084\101\097\109"]:GetPlayers())for C,c in ipairs(game.Workspace.Sparklers:GetChildren())do c.Sparkles.Enabled=false end end while true do if matchStarted then if C.Value<=0 then for C,c in ipairs(game.Workspace.Sparklers:GetChildren())do c.Sparkles.Enabled=true c.Sparkles.SparkleColor=Color3.fromRGB(255,162,0)end matchStarted=false wait(3)elseif c.Value<=0 then for C,c in ipairs(game.Workspace.Sparklers:GetChildren())do c.Sparkles.Enabled=true c.Sparkles.SparkleColor=Color3.fromRGB(138,0,126)end matchStarted=false wait(3)end else local C=table.getn(game.Teams["\080\117\114\112\108\101 \084\101\097\109"]:GetPlayers())local c=table.getn(game.Teams["\079\114\097\110\103\101 \084\101\097\109"]:GetPlayers())if C>0 and c>0 then newgame()end end wait(.5)end

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	
