This script is a goal system. There may be more than one broken part.
local Goal = script.Parent local debounce = false local GoalVal = script.Parent.Goals.Value 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 -- Might be 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
The problem here is that you assigned the values of the NumberValues to a variable. If you're going to do this, you can't add them together directly. Try this:
local Goal = script.Parent local debounce = false local GoalVal = script.Parent.Goals --Just gets the NumberValue, not the Value of it. 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.Value = GoalVal.Value + 1 -- Gets the value property 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
As far as I see, I should've fixed it. If anything else comes up, leave a comment below, and I'll see what I can do. Hope I helped :P