#My zone capturing system is not working well

1 messages · Page 1 of 1 (latest)

wooden notch
#

A

#
local Players = game:GetService("Players")
local player = Players.LocalPlayer

local event = ReplicatedStorage:WaitForChild("CaptureProgressEvent")
local gui = script.Parent 


local zones = {
    { id = "Zone1", label = "A" },
    { id = "Zone2", label = "B" },
    { id = "Zone3", label = "C" },
}

local BOX_SIZE = UDim2.fromScale(0.12, 0.16)
local BAR_HEIGHT = 0.2


local container = Instance.new("Frame")
container.Size = UDim2.fromScale(0.5, 0.2)
container.Position = UDim2.fromScale(0.5, 0)
container.AnchorPoint = Vector2.new(0.5, 0)
container.BackgroundTransparency = 1
container.Parent = gui

local layout = Instance.new("UIListLayout")
layout.FillDirection = Enum.FillDirection.Horizontal
layout.HorizontalAlignment = Enum.HorizontalAlignment.Center
layout.VerticalAlignment = Enum.VerticalAlignment.Top
layout.Padding = UDim.new(0.03,0)
layout.Parent = container


local zoneUI = {}
local zoneState = {}

for _, info in ipairs(zones) do
    local wrapper = Instance.new("Frame")
    wrapper.Size = BOX_SIZE
    wrapper.BackgroundTransparency = 1
    wrapper.Parent = container

    
    local box = Instance.new("Frame")
    box.Size = UDim2.fromScale(1, 1 - BAR_HEIGHT)
    box.BackgroundColor3 = Color3.fromRGB(120,120,120)
    box.BorderSizePixel = 0
    box.Parent = wrapper

    local corner = Instance.new("UICorner")
    corner.CornerRadius = UDim.new(0.2, 0)
    corner.Parent = box

    local text = Instance.new("TextLabel")
    text.Size = UDim2.fromScale(1, 1)
    text.BackgroundTransparency = 1
    text.Text = info.label
    text.TextScaled = true
    text.Font = Enum.Font.GothamBlack
    text.TextColor3 = Color3.new(1,1,1)
    text.Parent = box  ```
#
    barBG.Size = UDim2.fromScale(1, BAR_HEIGHT)
    barBG.Position = UDim2.fromScale(0, 1 - BAR_HEIGHT)
    barBG.BackgroundColor3 = Color3.fromRGB(35,35,35)
    barBG.BorderSizePixel = 0
    barBG.Parent = wrapper

    local barCorner = Instance.new("UICorner")
    barCorner.CornerRadius = UDim.new(0.4, 0)
    barCorner.Parent = barBG

    
    local bar = Instance.new("Frame")
    bar.Size = UDim2.fromScale(0, 1)
    bar.BackgroundColor3 = Color3.new(1,1,1)
    bar.BorderSizePixel = 0
    bar.Parent = barBG

    local barInnerCorner = Instance.new("UICorner")
    barInnerCorner.CornerRadius = UDim.new(0.4, 0)
    barInnerCorner.Parent = bar

    zoneUI[info.id] = {
        box = box,
        bar = bar
    }

    zoneState[info.id] = {
        captured = false,
        color = box.BackgroundColor3
    }
end

event.OnClientEvent:Connect(function(zoneId, progress, max, color, inZone, captured)
    local ui = zoneUI[zoneId]
    local state = zoneState[zoneId]
    if not ui or not state then return end

    if captured then
        state.captured = true
        state.color = color
        ui.bar.BackgroundColor3 = color
        ui.bar.Size = UDim2.fromScale(1,1)
        ui.box.BackgroundColor3 = color
        return
    end

    if not state.captured then
        if inZone then
            ui.bar.Size = UDim2.fromScale(math.clamp(progress/max,0,1),1)
            ui.bar.BackgroundColor3 = color

            if progress >= max then
                ui.box.BackgroundColor3 = color
            end
        else
            ui.bar.Size = UDim2.fromScale(0,1)
        end
    end
end) ```
#

I cant send video

sinful isle
#

whats the exact issue

wooden notch
#

I have a video but ı cant send it

sinful isle
#

can you

#

write it out

wooden notch
#

After one team takes over a zone, the bar doesn't show up when the other team is taking it.

#

I cant send rbxl file if you need

silver hollyBOT
#

studio** You are now Level 1! **studio

wooden notch
#

This is the problem

viscid knoll
#

maybe use zonesplus instead

wooden notch
#

I fixed thanks