local Goal = script.Parent
local debounce = false
local GoalVal = script.Parent.Goals

function onTouch(part)
	local Ball = part.Parent:findFirstChild("ScoreBall")
	if Ball ~= nil and debounce == false then
		local Mes = Instance.new("Message")
		Mes.Text = "Blue Team Scored!"
		Mes.Parent = game.Workspace
		GoalVal = GoalVal + 1 --HERE
		wait(5)
		local pl = game.Players:GetChildren()
		for i=1,#pl do
		pl[i].Character.Humanoid.Health = 0
		Mes:Remove()
		end
	end
	end

Goal.Touched:connect(onTouch)

function Endgame()
	wait(4.9)
	local pla = game.Players:GetChildren()
		for i=1,#pla do
		pla[i].TeamColor = "Lavender"
	end
end

if GoalVal.Value == 2 then Endgame()
end