Bad argument #1 to 'for iterator' (table expected, got nil)

I got the error and dont know whats working wrong can someone help me?

error line:
– Iterate through all the mines
for i, mine in ipairs(mines) do

Code:

– Function to check if a vehicle is on a mine
function checkMines()
– Iterate through all the mines
for i, mine in ipairs(mines) do
– Check if there’s a vehicle on the mine
if DoesEntityExist(mine) then
local x, y, z = table.unpack(GetEntityCoords(mine))
local nearbyVehicle = GetClosestVehicle(x, y, z, 2.0, 0, 70)
if DoesEntityExist(nearbyVehicle) then
– Explode the mine
SetEntityAsMissionEntity(mine, true, true)
DeleteObject(mine)

            -- Create explosion effect
            x, y, z = table.unpack(GetEntityCoords(nearbyVehicle))
            AddExplosion(x, y, z, 3, 1.0, true, false, 1.0)

            -- Remove the mine from the table
            table.remove(mines, i)
        end
    end
end

end

if u need more informations about the script just drop it down will reply with the code

can you provide a scrennshot of the error and the line of code that the error said please

The error seems to indicate that “mines” is not a table variable in your file, it seems “mines” is not any variable at all actually. Nil values are non-existent values.

Got it worked i formed the complete code new and now working