local Config = {
CaptureTime = 5,
WaitTimePerPointIncrease = 1.9,
CaptureSecondsIncreaseTime = .5,
SecondsUpdaterTweenTime = .2,
PointMaxPointAmount = 10
}
type Point = {
Capturable: BoolValue,
CapturedBy: StringValue,
Points: NumberValue,
capturedSeconds: NumberValue,
touchPart: Part
} & Part
type Points = {
Point
}
local PointA = game.Workspace.A
local PointB = game.Workspace.B
local PointC = game.Workspace.C
local Raiders = game.Teams.Raiders
local Defenders = game.Teams.Defenders
local CurrentPoint = nil :: Point
local CurrentPointConnect = nil
local function updatePointsLabel()
for _, Player in ipairs(game:GetService("Players"):GetPlayers()) do
local PlayerGUI = Player:FindFirstChild("PlayerGui")
if PlayerGUI then
local pointsLabel = PlayerGUI:FindFirstChild("RobloxStyledTerminal")
if pointsLabel then
local Frame = pointsLabel:FindFirstChild("LeftFrame")
if Frame then
local pointCount = Frame:FindFirstChild("PointCount")
if pointCount then
pointCount.Text = tostring(CurrentPoint.Points.Value)
end
end
end
end
end
end
local function UpdateSeconds()
task.spawn(function()
local tweenInfo = TweenInfo.new(Config.SecondsUpdaterTweenTime) -- Every time the bar changes, it will tween to the desired size over the span of 0.2 seconds
for _, Player in ipairs(game:GetService("Players"):GetPlayers()) do
local PlayerGUI = Player:FindFirstChild("PlayerGui")
if PlayerGUI then
local pointsLabel = PlayerGUI:FindFirstChild("RobloxStyledTerminal")
if pointsLabel then
local progress_percent = CurrentPoint.capturedSeconds.Value/Config.CaptureTime
local newTween = game:GetService("TweenService"):Create(PlayerGUI.RobloxStyledTerminal.LeftFrame.PointBar, tweenInfo, {
Size = UDim2.new(progress_percent, 0, 1, 0)
})
if Player.TeamColor == Raiders.TeamColor then
PlayerGUI.RobloxStyledTerminal.LeftFrame.PointBar.BackgroundColor3 = Color3.fromRGB(255,0,0)
newTween:Play()
else
PlayerGUI.RobloxStyledTerminal.LeftFrame.PointBar.BackgroundColor3 = Color3.fromRGB(0,0,255)
newTween:Play()
end
end
end
end
end)
end
local function GetPlayerTeam(Player)
return (Player.TeamColor == Defenders.TeamColor and "Def" or (Player.TeamColor == Raiders.TeamColor and "Raid" or nil))
end
local Table = {}
local function CapturableCheck(Point, Team)
if typeof(Point:GetTouchingParts()) == "table" and typeof(workspace:GetPartBoundsInBox(Point.CFrame, Point.Size)) then
for _, Part in ipairs(workspace:GetPartBoundsInBox(Point.CFrame, Point.Size)) do
for _, Player in ipairs(game:GetService("Players"):GetPlayers()) do
if Player.Character:IsAncestorOf(Part) and GetPlayerTeam(Player) ~= Team then
return false
end
end
end
end
return true
end
local function Connect(Point: Point)
return Point.Points.Changed:Connect(function()
task.spawn(updatePointsLabel)
task.spawn(UpdateSeconds)
end)
end
local function CombineTables(Table1, Table2)
Table = {}
for _, Val in ipairs(Table1) do
if not table.find(Table, Val) then
table.insert(Table, Val)
end
end
for _, Val in ipairs(Table2) do
if not table.find(Table, Val) then
table.insert(Table, Val)
end
end
return Table
end
local HitboxCheckDB = false
local TweenService = game:GetService('TweenService')
local function HitboxCheck(Part: Part, Player : Player)
if HitboxCheckDB == true then return end
HitboxCheckDB = true
local capturedSeconds = Part:FindFirstChild("capturedSeconds")
while ((GetPlayerTeam(Player) == "Raid" and capturedSeconds.Value < Config.CaptureTime) or (GetPlayerTeam(Player) == "Def" and capturedSeconds.Value > 0 and capturedSeconds.Value <= Config.CaptureTime)) do
if typeof(Part:GetTouchingParts()) == "table" and typeof(workspace:GetPartBoundsInBox(Part.CFrame, Part.Size)) == "table" then
for _, part in ipairs(Part:GetTouchingParts()) do
if Player.Character:IsAncestorOf(part) and table.find(workspace:GetPartBoundsInBox(Part.CFrame, Part.Size), part) and CapturableCheck(Part, GetPlayerTeam(Player)) then
capturedSeconds.Value = capturedSeconds.Value + (GetPlayerTeam(Player) == "Raid" and 1 or (GetPlayerTeam(Player) == "Def") and -1 or 0)
break
end
end
end
task.wait(Config.CaptureSecondsIncreaseTime)
print("a")
end
HitboxCheckDB = false
end
local GivePointsDB = false
local function SetUpPoints(...)
local Points = {...} :: Points
if not CurrentPoint then
CurrentPoint = Points[1] :: Point
CurrentPointConnect = Connect(CurrentPoint)
end
for Index, Point : Point in ipairs(Points) do
if Point.CapturedBy.Value == "" then Point.CapturedBy.Value = "Def" end
task.spawn(function()
Point.Touched:Connect(function(part)
if Point.Captureable.Value == true then
local Player = game:GetService("Players"):GetPlayerFromCharacter(part.Parent)
if Player then
local PlayerTeam = GetPlayerTeam(Player)
if not PlayerTeam then return end
local PlayerTeamMaxPoints = (PlayerTeam == "Raid" and Config.PointMaxPointAmount or 0)
HitboxCheck(Point, Player)
if ((PlayerTeam == "Raid" and Point.capturedSeconds.Value == Config.CaptureTime) or (PlayerTeam == "Def" and Point.capturedSeconds.Value == 0)) and PlayerTeam ~= Point.CapturedBy.Value and ((PlayerTeam == "Raid" and Point.Points.Value >= 0) or (PlayerTeam == "Def" and Point.Points.Value <= Config.PointMaxPointAmount)) and not ((PlayerTeam == "Raid" and Point.Points.Value == Config.PointMaxPointAmount) or (PlayerTeam == "Def" and Point.Points.Value == 0)) then
GivePointsDB = true
Point.CapturedBy.Value = PlayerTeam
while Point.Captureable.Value == true and ((PlayerTeam == "Raid" and Point.Points.Value >= 0) or (PlayerTeam == "Def" and Point.Points.Value <= Config.PointMaxPointAmount)) and not ((PlayerTeam == "Raid" and Point.Points.Value == Config.PointMaxPointAmount) or (PlayerTeam == "Def" and Point.Points.Value == 0)) and Point.CapturedBy.Value == PlayerTeam do
task.wait(Config.WaitTimePerPointIncrease)
Point.Points.Value = Point.Points.Value + (PlayerTeam == "Raid" and 1 or (PlayerTeam == "Def") and -1 or 0)
if Point.Points.Value == PlayerTeamMaxPoints then
Point.Captureable.Value = false
if not Points[Index - 1] and PlayerTeam == "Def" then
Point.Captureable.Value = true
end
if Points[Index + 1] and PlayerTeam == "Raid" then
Points[Index + 1].Captureable.Value = true
CurrentPointConnect:Disconnect()
CurrentPoint = Points[Index + 1]
CurrentPointConnect = Connect(CurrentPoint)
elseif Points[Index - 1] and PlayerTeam == "Def" then
Points[Index - 1].Captureable.Value = true
CurrentPointConnect:Disconnect()
CurrentPoint = Points[Index - 1]
CurrentPointConnect = Connect(CurrentPoint)
end
GivePointsDB = false
break
end
end
GivePointsDB = false
end
end
end
end)
end)
end
end
SetUpPoints(PointA, PointB, PointC)SetUpPoints(PointA, PointB, PointC)
As shown in video below, when player touches the Part GUI doesn’t get filled. It only does when terminal is fully captured. What did I do wrong?