Good morning guys, so i got this problem while making my Control Points/Flag system which i dont know why appears, the console says this:
local max_radius_size = 20
local part = game.Workspace.Part
local CurrentTeam
local capturing = game.ReplicatedStorage.Capturing
local CanCapture = game.ReplicatedStorage.CapturingInside.Value
local capturers = 0
local captureProgressValue = game.ReplicatedStorage.CaptureProgress.Value
local defenders = 0
local alliesTable = {}
local axisTable = {}
while true do
wait()
for i, playersCircle in pairs(game.Players:GetPlayers()) do
local char = playersCircle.Character or playersCircle.CharacterAdded:Wait()
local PlayerTeam = char:WaitForChild("TeamValue").Value
if PlayerTeam == "Allies" then
table.insert(alliesTable, 1, PlayerTeam)
else
table.insert(axisTable, 1, PlayerTeam)
end
local distance = (char.HumanoidRootPart.Position - part.Position).Magnitude
if distance < max_radius_size then
if CurrentTeam == nil and CanCapture then
repeat
wait(1)
captureProgressValue += 0.5
capturing:FireClient( playersCircle,CurrentTeam, captureProgressValue)
until captureProgressValue == 2.5
else
if PlayerTeam ~= CurrentTeam then
capturers += 1
end
end -- second one lol
if distance > max_radius_size then
CanCapture = true
end
end -- first If statement
end -- for i, v in pairs() loop
end -- while true do line
LOCAL SCRIPT WHERE ERROR APPEARS
local capturingEvent = game.ReplicatedStorage.Capturing
local Base = script.Parent.ProgressBar.Base
-- Set the progress of the bar
-- progress is a number between 0 and 1
local function SetProgress(progress)
local oneOverProgress
if progress == 0 then
-- since you can't do 1/0 (it's undefined), we'll just make oneOverProgress = 0
oneOverProgress = 0
else
oneOverProgress = 1/progress
end
Base.Clipping.Size = UDim2.new(progress, 0, 1, 0) -- set Clipping size to {progress, 0, 1, 0}
Base.Clipping.Top.Size = UDim2.new(oneOverProgress, 0, 1, 0) -- set Top size to {1/progress, 0, 1, 0}
end
capturingEvent.OnClientEvent:Connect(function(currentTeam, captureProcess)
Base.Visible = true
wait(1)
SetProgress(captureProcess.Value)
print(captureProcess.Value)
end)
game.ReplicatedStorage.CapturingInside.Changed:Connect(function()
Base.Visible = false
end)
Thanks in advance!!!
Also what do you think of my flag system? its good?