local I=game:GetService("\083\101\114\118\101\114\083\099\114\105\112\116\083\101\114\118\105\099\101")local A=I:WaitForChild("\065\103\101\110\116\115",2)local e=require(A:WaitForChild("\083\111\108\100\105\101\114\065\105",1))local X=require(A:WaitForChild("\068\101\115\116\114\111\121\083\101\114\118\105\099\101",1))local a={SoldatBrain=nil}function a.new(I)if I:FindFirstChild("\071\117\110")==nil or I:FindFirstChild("\071\117\110")~=nil and not(I:FindFirstChild("\071\117\110")):IsA("\084\111\111\108")then((I:WaitForChild("\071\117\110\083\116\111\114\097\103\101")):WaitForChild("\071\117\110")).Parent=I end local A=e.new(I)local function a(I)for I,A in pairs(I:GetChildren())do a(A)end local A if I:IsA("\080\097\114\116")then A=math.random(5,10)else A=11 end X:AddItem(I,A)end I.Humanoid.Died:connect(function()A.Stop()math.randomseed(tick())a(I)end)end return a
local ServerScriptService = game:GetService("ServerScriptService")

local agentsFolder = ServerScriptService:WaitForChild("Agents", 2)

local soldatAi = require(agentsFolder:WaitForChild("SoldierAi", 1))
local DestroyService = require(agentsFolder:WaitForChild("DestroyService", 1))

local soldierAgent = {
    SoldatBrain = nil
}

function soldierAgent.new(soldierModel)
    -- MOVE THIS TO THE MODEL SPAWN PROCESS??
    if soldierModel:FindFirstChild("Gun") == nil or 
	    soldierModel:FindFirstChild("Gun") ~= nil and not soldierModel:FindFirstChild("Gun"):IsA("Tool") then
	    soldierModel:WaitForChild("GunStorage"):WaitForChild("Gun").Parent = soldierModel
    end
    
    local soldatBrain = soldatAi.new(soldierModel)
    local function clearParts(parent)
        for _, part in pairs(parent:GetChildren()) do
            clearParts(part)
        end
        local delay
        if parent:IsA("Part") then
            delay = math.random(5,10)
        else
            delay = 11
        end
        DestroyService:AddItem(parent, delay)
    end
    
    soldierModel.Humanoid.Died:connect(function()
        soldatBrain.Stop()
        math.randomseed(tick())
        clearParts(soldierModel)
    end)

    
end

return soldierAgent


