Making bitcoin script need help want it to start over again instead of disapearing

hi i am using a script that when you place a rig, your rig is mining bitcoin or other coins.

the problem is i am trying t make it miner over after giving the bitcoin it mined before… the default script make it disapear … the machine burns out and you lost the prop.

here is the part of the code… i tried a few thing but cant figure out where i could copy some lines to make it mine again after the timer is over…

segaSupakTimer = function()
    K = Config.MiningTime
    J = Config.MiningTime
    for m = 1, Config.MiningTime do
        Citizen.Wait(1000)
        J = J - 1
        K = K - 1
    end
    G = false
    amount = ("%.8f"):format(math.random(1, 7000) / 1000)
    TriggerServerEvent("esegovic:updateCrypto", "bitcoin", amount)
    ESX.ShowNotification(Config.Translate[920])
    ESX.ShowNotification(Config.Translate[921] .. amount .. "~s~ BTC")
end
SpawnPropRig1 = function()
    local L = PlayerPedId()
    H = GetEntityCoords(L)
    local M = GetHashKey("v_corp_servers1")
    while not HasModelLoaded(M) do
        Citizen.Wait(0)
        RequestModel(M)
    end
    local o, p, q = table.unpack(H)
    local N = vector3(o + 0.1, p + 0.1, q)
    local O = CreateObject(M, N, true)
    local P = GetEntityCoords(L, true)
    local Q = GetEntityCoords(O, true)
    local R = GetEntityHeading(PlayerPedId())
    SetEntityHeading(O, R)
    PlaceObjectOnGroundProperly(O)
    FreezeEntityPosition(O, true)
    I = true
    esegaSupakTimer()

  ITS HERE i deleted the deleteentity
i tried to put some lines but the script is broken when i do something here....
if i put UseRig1() it place a new rig down for the count,..
i only need for the prop to calcultate again..

end


Citizen.CreateThread(
    function()
        while true do
            if I then
                Wait(0)
                local S = GetEntityCoords(PlayerPedId())
                local T = #(H - S)
                if T < 15 then
                    local U = math.random() + math.random(0, 999999)
                    local o, p, q = table.unpack(H)
                    local V = vector3(o, p, q + 0.1)
                    local W = vector3(o, p, q + 0.2)
                    ESX.Game.Utils.DrawText3D(V, Config.Translate[923] .. U .. Config.Translate[924], 0.5)
                    ESX.Game.Utils.DrawText3D(
                        W,
                        Config.Translate[925] .. K .. " / " .. Config.MiningTime .. " sec",
                        0.5
                    )
                end
            else
                Wait(500)
            end
        end
    end
)
UseRig1 = function()
    local h = PlayerPedId()
    exports[Config.FolderNameMythicProgbar]:Progress(
        {
            name = "unique_action_name",
            duration = 6000,
            label = Config.Translate[919],
            useWhileDead = true,
            canCancel = true,
            controlDisables = {
                disableMovement = true,
                disableCarMovement = true,
                disableMouse = false,
                disableCombat = true
            },
            animation = {animDict = "mini@repair", anim = "fixing_a_player"}
        },
        function(C)
            if not C then
                ClearPedTasks(h)
            else
                ClearPedTasks(h)
            end
        end
    )


    Citizen.Wait(6000)
    SpawnPropRig1()
end

i managed to mnake it almost work out…

   (here is i want to make a loop
K = Config.MiningTime
    J = Config.MiningTime
    for m = 1, Config.MiningTime do
        Citizen.Wait(1000)
        J = J - 1
        K = K - 1
    end


G = false
    amount = ("%.8f"):format(math.random(1, 7000) / 1000)
    TriggerServerEvent("esegovic:updateCrypto", "bitcoin", amount)
    ESX.ShowNotification(Config.Translate[920])
    ESX.ShowNotification(Config.Translate[921] .. amount .. "~s~ BTC")

goto esegaSupakTimer() (there is the loop i want to do)

end


type or paste code here

found it by looping