Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to create a good domination flare system?

Asked by 6 years ago

I want to create a domination flare system, but if the player is a 12 magnitude distance to a point, the Gui was deleted by other point because the player is not a 12 magnitude distance from this, so how to fix this and how to create a good domination flare system?

Example

local SpotPoint = script.Parent

--< Services
local PlayerService = game:GetService('Players')
local TeamService = game:GetService('Teams')
local RunService = game:GetService('RunService')
local TweenService = game:GetService('TweenService')
local WorkspaceSergice = game:GetService('Workspace')
local RStorageService = game:GetService('ReplicatedStorage')

--< Functions
local FindObject = function(Place, Object)
    for _, Obj in pairs(Place:GetChildren()) do
        if Obj:IsA('BasePart') and Obj.name == Object then
            return Obj
        end
    end
end

--< Variables
local PlrFolder = {}

local TeamCapt

local Ring = FindObject(SpotPoint, 'Ring')
local SmallRing = FindObject(SpotPoint, 'SmallRing')
local Center = FindObject(SpotPoint, 'Center')
local Border = FindObject(SpotPoint, 'Border')

local distance = 12

--< Corutines
spawn(function()
    RunService.Stepped:Connect(function()
        Border.CFrame = Border.CFrame * CFrame.Angles(-.01, 0, 0)
        Ring.CFrame = Ring.CFrame * CFrame.Angles(.01, 0, 0)
        SmallRing.CFrame = SmallRing.CFrame * CFrame.Angles(-.005, 0, 0)
    end)
end)

--< Events
PlayerService.PlayerAdded:Connect(function(Player)
    PlrFolder[Player] = {CapTime = 0}
end)

--< Loops
spawn(function()
    while wait(1) do
        if TeamCapt then
            RStorageService[TeamCapt.Name].Value = RStorageService[TeamCapt.Name].Value + 1
        end
    end
end)

while wait() do
    local PlrCap = 0
    for _, Players in pairs(PlayerService:GetChildren()) do
        if Players and Players.Character and (Players.Character:WaitForChild('HumanoidRootPart').Position - Center.Position).magnitude <= distance and TeamCapt ~= Players.Team then
            if PlrFolder[Players]['CapTime'] > 50 then
                TeamCapt = Players.Team
                local Update = {}
                if Players.Team == TeamService.Raiders then
                    Update.Color = Color3.fromRGB(117, 0, 0)
                elseif Players.Team == TeamService.Resistance then
                    Update.Color = Color3.fromRGB(163, 143, 97)
                end
                local up1 = TweenService:Create(Ring, TweenInfo.new(2), Update)
                local up2 = TweenService:Create(SmallRing, TweenInfo.new(2), Update)
                local up3 = TweenService:Create(Center, TweenInfo.new(2), Update)
                local up4 = TweenService:Create(Border, TweenInfo.new(2), Update)

                up1:Play()
                up2:Play()
                up3:Play()
                up4:Play()
            else
                if Players.PlayerGui:FindFirstChild('CaptureGui') == nil then
                    local UI = RStorageService.CaptureGui:Clone()
                    UI.Parent = Players.PlayerGui
                end
                Players.PlayerGui.CaptureGui.BackBar.Bar.Size = UDim2.new((PlrFolder[Players]['CapTime'] * 100 / 50) * 0.01, 0,0, 10)
                PlrFolder[Players]['CapTime'] = PlrFolder[Players]['CapTime'] + 1
            end
        else
            if Players.PlayerGui:FindFirstChild('CaptureGui') ~= nil then
                Players.PlayerGui.CaptureGui:Destroy()
            end
            PlrFolder[Players]['CapTime'] = 0
        end
    end
end

Answer this question