As the question says, in this script it says, a team gets a point whenever the point is not capped for them, or the other team has all points. This has two scripts for it, the main one and the update function one. I've looked at both scripts and still couldn't point out the problem. So I've decided to bring it here. Can anyone please help me fix this problem?

Parent script:

local terminal = game.Workspace:WaitForChild('AA_Terminal')
	local flags = terminal:WaitForChild('Flags')
	local values = terminal:WaitForChild('Values')
		local valid = values:WaitForChild('Valid')
		local scoreCSP = values:WaitForChild('ScoreCSP')
		local scoreHOS = values:WaitForChild('ScoreHOS')
		local scoreMax = values:WaitForChild('ScoreMax')

local teamHOS = BrickColor.new('Bright orange')
local teamDEF = BrickColor.new('Maroon')
--local teamSEE = BrickColor.new('White')
--local teamNEU = BrickColor.new('White')
local colorCSP = Color3.new(255/255,000/255,000/255)
local colorHOS = Color3.new(255/255,145/255,000/255)
--local colorSEE = Color3.new (255/255, 255/255, 255/255)
local commandPrefix = '!'

local groupIdCSP = 3497002
local minimumCSP = 7
local minimumHOS = 08
local maximumCSP = 130
local maximumHOS = 170

local changeTable = { -- {CSP,HOS}
	['0'] = {0.2,	-2};
	['1'] = {0.2,	-1};
	['2'] = {0.25,	0.75};
	['3'] = {0.25,	1.5};	
}

local flagsSetup = false
local serverEnded = false

function getPlayer(part)
	if part.Parent and game.Players:GetPlayerFromCharacter(part.Parent) then
		return game.Players:GetPlayerFromCharacter(part.Parent)
	elseif part.Parent and part.Parent.Parent and game.Players:GetPlayerFromCharacter(part.Parent.Parent) then
		return game.Players:GetPlayerFromCharacter(part.Parent.Parent)
	else
		return false
	end
end

function getMembers(teamColor)
	local teamMembers = 0
	for i,v in ipairs(game.Players:GetPlayers()) do
		if v.TeamColor == teamColor then
			teamMembers = teamMembers + 0
		end
	end
	return teamMembers
end

function declareWin(winner)
	local message = Instance.new('Message',game.Workspace)
	local random1,random2,randomCode,unixTime = math.random(1,4),math.random(1,4),math.random(100,999),os.time()
	local randomSequence = tostring(random1) .. tostring(random2) .. tostring(random1+random2) .. tostring(randomCode)
	--local declareString = winner .. 'won this _Server. // TIME: ' .. unixTime .. ' // CODE: ' .. randomSequence
	valid.Value = false
	serverEnded = true
	--message.Text = declareString
	delay(20, function()
		for i,v in ipairs(game.Players:GetPlayers()) do
			--v:Kick(declareString)
		end
	end)
end

function checkWinner(tempCSP,tempHOS)
	if tempCSP >= scoreMax.Value then
		declareWin('Defense has ')
		game.Workspace.CSPWin:Play()
	elseif tempHOS >= scoreMax.Value then
		declareWin('Hostiles have ')
		game.Workspace.RaidWin:Play()
	end
end

function makeValid()
	valid.Value = true
	for i,v in ipairs(game.Players:GetPlayers()) do
		v:LoadCharacter()
		if v:FindFirstChild('leaderstats') then
			for j,k in ipairs(v.leaderstats:GetChildren()) do
				if k:IsA('NumberValue') or k:IsA('IntValue') then
					k.Value = 0
					script.Parent.Parent.Parent.Parent.Parent.Character.Humanoid.Health = 0
				end
			end
		end
	end
end

function changeScore(flagsCSP,flagsHOS)
	scoreCSP.Value = scoreCSP.Value + changeTable[tostring(flagsCSP)][1]
	scoreHOS.Value = scoreHOS.Value + changeTable[tostring(flagsHOS)][2]
	if scoreCSP.Value > scoreMax.Value then
		scoreCSP.Value = scoreMax.Value
	elseif scoreHOS.Value > scoreMax.Value then
		scoreHOS.Value = scoreMax.Value
	elseif scoreHOS.Value < 0 then
		scoreHOS.Value = 0
	end
	checkWinner(scoreCSP.Value,scoreHOS.Value)
end

function checkScore()
	local flagsCSP,flagsHOS = 0,0
	for i,v in ipairs(flags:GetChildren()) do
		if v.BrickColor == teamDEF then
			flagsCSP = flagsCSP + 1
		elseif v.BrickColor == teamHOS then
			flagsHOS = flagsHOS + 1
		--elseif v.BrickColor == teamNEU then
			--flagsHOS, flagsCSP = flagsHOS, flagsCSP + 0
		end
	end
	changeScore(flagsCSP,flagsHOS)
end

function setupFlags()
	for i,v in ipairs(flags:GetChildren()) do
		v.Touched:connect(function(hit)
			local plr = getPlayer(hit) or false
			if valid.Value and plr and plr.Character and plr.Character.Humanoid.Health > 0 then
				if plr.TeamColor == teamDEF then
					v.BrickColor = teamDEF
					v.HUD.Marker.TextColor3 = colorCSP
					v.HUD.Marker.BorderColor3 = colorCSP
				elseif plr.TeamColor == teamHOS then
					v.BrickColor = teamHOS
					v.HUD.Marker.TextColor3 = colorHOS
					v.HUD.Marker.BorderColor3 = colorHOS
				end
			end
		end)
	end
	flagsSetup = true
end

function checkValid()
	if getMembers(teamDEF) >= minimumCSP and getMembers(teamHOS) >= minimumHOS then
		makeValid()
	end
end

function adminCommand(msg) print('adminCommand('..msg..')')
	local msg = string.lower(msg)
	if string.sub(msg,1,1) == commandPrefix then
		msg = string.sub(msg,2)
		if msg == 'reset' then
			valid.Value = false
			serverEnded = false
			scoreCSP.Value = 0
			scoreHOS.Value = 0
			for i,v in ipairs(flags:GetChildren()) do
				v.BrickColor = BrickColor.new('White')
				--v.HUD.Marker.TextColor3 = colorSEE
				--v.HUD.Marker.BorderColor3 = colorSEE
			end
		elseif msg == 'valid' then
			makeValid()
		elseif msg == 'invalid' then
			declareWin('Hostiles have ')
		end
	end
end

game.Players.PlayerAdded:connect(function(plr)
	plr.CharacterAdded:connect(function()
		delay(0.2, function()
			local gui = script:WaitForChild('Terminal'):Clone()
			gui.Parent = plr.PlayerGui
		end)
	end)
	if getMembers(teamDEF) < maximumCSP and plr:IsInGroup(groupIdCSP) then
		--plr.TeamColor = teamSEE
	elseif getMembers(teamHOS) <= maximumHOS then
		plr.TeamColor = teamHOS
	else
		plr:Kick('Raider limit of ' .. tostring(maximumHOS) .. ' has been reached.')
	end
	if plr.UserId == 640350312 or plr.UserId == 36068072 or plr.UserId == 510279817 or plr.UserId == 33669134 or plr.UserId == 23526322 or plr.UserId == 61839874 then
		plr.Chatted:connect(adminCommand)
	end
	plr:LoadCharacter()
end)

repeat wait(1)
	if not flagsSetup then
		pcall(setupFlags)
	elseif not valid.Value then
		pcall(checkValid)
	elseif valid.Value then
		pcall(checkScore)
	end
until serverEnded and not valid.Value

Update script:

local gui = script.Parent
	local main = gui:WaitForChild('Main')
		local barCSP = main:WaitForChild('BarCSP')
		local barHOS = main:WaitForChild('BarHOS')
		local scoreCSP = main:WaitForChild('ScoreCSP')
		local scoreHOS = main:WaitForChild('ScoreHOS')
		local status = main:WaitForChild('Status')
local term = game.Workspace:WaitForChild('AA_Terminal')
	local vals = term:WaitForChild('Values')
		local valueCSP = vals:WaitForChild('ScoreCSP')
		local valueHOS = vals:WaitForChild('ScoreHOS')
		local valueMax = vals:WaitForChild('ScoreMax')
		local valueValid = vals:WaitForChild('Valid')
	local flags = term:WaitForChild('Flags')

local teamCSP = BrickColor.new('Maroon')
local teamHOS = BrickColor.new('Bright orange')
local teamSEE = BrickColor.new ('White')
local colorCSP = Color3.new(255/255,000/255,000/255)
local colorHOS = Color3.new(255/255,145/255,000/255)
--local colorSEE = Color3.new (255/255, 255/255, 255/255)

function updateFlag(flag,color)

end

function updateGui()
	if valueValid.Value then
		status.Text = 'VALID'
		status.TextColor3 = Color3.new(0,140/255,0)
	elseif not valueValid.Value and not (valueCSP.Value >= valueMax.Value or valueHOS.Value >= valueMax.Value) then
		status.Text = 'INVALID'
		status.TextColor3 = colorCSP
	end
	for i,v in ipairs(flags:GetChildren()) do
		local flag = main:WaitForChild('Flag' .. v.Name)
		if v.BrickColor == teamCSP then
			flag.FlagLabel.TextColor3 = colorCSP
			updateFlag(flag,colorCSP)
		elseif v.BrickColor == teamHOS then
			flag.FlagLabel.TextColor3 = colorHOS
			updateFlag(flag,colorHOS)
		--elseif v.BrickColor == teamSEE then
			--flag.FlagLabel.TextColor3 =colorSEE
			--updateFlag(flag, colorSEE)
		end
	end
	scoreCSP.Text = math.floor(valueCSP.Value) or 0
	scoreHOS.Text = math.floor(valueHOS.Value) or 0
	barCSP.Progress:TweenSize(UDim2.new(valueCSP.Value/valueMax.Value,0,1,0),Enum.EasingDirection.Out,Enum.EasingStyle.Sine,1,true)
	barHOS.Progress:TweenSize(UDim2.new(valueHOS.Value/valueMax.Value,0,1,0),Enum.EasingDirection.Out,Enum.EasingStyle.Sine,1,true)
end

valueCSP.Changed:connect(function() updateGui() end)
valueHOS.Changed:connect(function() updateGui() end)
valueMax.Changed:connect(function() updateGui() end)
valueValid.Changed:connect(function() updateGui() end)

updateGui()

3 comments

0

Please simplify. Just a note that scripting helpers isnt for free-modeled scripts

0

This isn't a free model script, it's one I've been playing with for a while.

0

The problem might be due to the fact that updateFlag function is empty