Шаг за шагом реши проблему в коде.
[ML] (error) Z.lua: ...rams\Arizona Games Launcher\bin\arizona\moonloader\Z.lua:13: stack overflow
stack traceback:
	...rams\Arizona Games Launcher\bin\arizona\moonloader\Z.lua:13: in function 'getObjectCoordinates'
	...rams\Arizona Games Launcher\bin\arizona\moonloader\Z.lua:13: in function 'getObjectCoordinates'
	...rams\Arizona Games Launcher\bin\arizona\moonloader\Z.lua:13: in function 'getObjectCoordinates'
	...rams\Arizona Games Launcher\bin\arizona\moonloader\Z.lua:13: in function 'getObjectCoordinates'
	...rams\Arizona Games Launcher\bin\arizona\moonloader\Z.lua:13: in function 'getObjectCoordinates'
	...rams\Arizona Games Launcher\bin\arizona\moonloader\Z.lua:13: in function 'getObjectCoordinates'
	...rams\Arizona Games Launcher\bin\arizona\moonloader\Z.lua:13: in function 'getObjectCoordinates'
	...rams\Arizona Games Launcher\bin\arizona\moonloader\Z.lua:13: in function 'getObjectCoordinates'
	...rams\Arizona Games Launcher\bin\arizona\moonloader\Z.lua:13: in function 'getObjectCoordinates'
	...rams\Arizona Games Launcher\bin\arizona\moonloader\Z.lua:13: in function 'getObjectCoordinates'
	...
	...rams\Arizona Games Launcher\bin\arizona\moonloader\Z.lua:13: in function 'getObjectCoordinates'
	...rams\Arizona Games Launcher\bin\arizona\moonloader\Z.lua:13: in function 'getObjectCoordinates'
	...rams\Arizona Games Launcher\bin\arizona\moonloader\Z.lua:13: in function 'getObjectCoordinates'
	...rams\Arizona Games Launcher\bin\arizona\moonloader\Z.lua:13: in function 'getObjectCoordinates'
	...rams\Arizona Games Launcher\bin\arizona\moonloader\Z.lua:13: in function 'getObjectCoordinates'
	...rams\Arizona Games Launcher\bin\arizona\moonloader\Z.lua:13: in function 'getObjectCoordinates'
	...rams\Arizona Games Launcher\bin\arizona\moonloader\Z.lua:13: in function 'getObjectCoordinates'
	...rams\Arizona Games Launcher\bin\arizona\moonloader\Z.lua:13: in function 'getObjectCoordinates'
	...rams\Arizona Games Launcher\bin\arizona\moonloader\Z.lua:13: in function 'getObjectCoordinates'
	...rams\Arizona Games Launcher\bin\arizona\moonloader\Z.lua:23: in function 'checkObjectsInRadius'
	...rams\Arizona Games Launcher\bin\arizona\moonloader\Z.lua:83: in function <...rams\Arizona Games Launcher\bin\arizona\moonloader\Z.lua:82

```lua
local vector = require "vector3d"

function calculateDistance(v1, v2)
    return getDistanceBetweenCoords3d(v1.x, v1.y, v1.z, v2.x, v2.y, v2.z)
end

function getPlayerCoordinates()
    local x, y, z = getCharCoordinates(PLAYER_PED)
    return vector(x, y, z)  -- Создаём вектор из возвращаемых координат
end

function getObjectCoordinates(object)
    local x, y, z = getObjectCoordinates(object)  -- Используем встроенную функцию без переопределения
    return vector(x, y, z)  -- Создаём вектор из возвращаемых координат
end

function checkObjectsInRadius(radius, targetModelIDs)
    local playerPos = getPlayerCoordinates()
    sampAddChatMessage("Игрок в позиции: " .. tostring(playerPos), -1)

    for _, object in pairs(getAllObjects()) do
        if doesObjectExist(object) then
            local objectPos = getObjectCoordinates(object)  -- Получаем координаты объекта
            local distance = calculateDistance(playerPos, objectPos)

            if distance <= radius then
                local objectModel = getObjectModel(object)
                sampAddChatMessage("Объект найден: " .. tostring(objectModel) .. " на расстоянии: " .. tostring(distance), -1)

                for _, modelID in ipairs(targetModelIDs) do
                    if objectModel == modelID then 
                        return true, object, objectPos 
                    end
                end
            end
        end
    end

    sampAddChatMessage("Нет объектов в радиусе " .. tostring(radius), -1)
    return false
end

function isPlayerNearObject(object, radius)
    local objectPos = getObjectCoordinates(object)  -- Получаем координаты объекта
    for _, player in pairs(getAllChars()) do
        if doesCharExist(player) and not isCharDead(player) and player ~= PLAYER_PED then
            local playerPos = getPlayerCoordinates()  -- Получаем координаты игрока
            local playerDistance = calculateDistance(objectPos, playerPos)
            if playerDistance <= radius then 
                return true 
            end
        end
    end
    return false
end

local keysData = {
    [1024] = {structElement = 4, size = 2},
    [32] = {structElement = 4, size = 2}
}

function sendkey(keyCode)
    local _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
    local mem, data = allocateMemory(68), keysData[keyCode]

    if data then
        sampStorePlayerOnfootData(id, mem)
        setStructElement(mem, data.structElement, data.size, keyCode, false)
        sampSendOnfootData(mem)
        setStructElement(mem, data.structElement, data.size, 0, false)
        sampSendOnfootData(mem)
    end

    freeMemory(mem)
end

function main()
    while not isSampAvailable() do
        wait(0)
    end

    sampRegisterChatCommand("mainbot", function()
        local found, object, objectPos = checkObjectsInRadius(10, {19300, 854, 3930})
        
        if found then
            local playerPos = getPlayerCoordinates()
            local playerDistance = calculateDistance(playerPos, objectPos)
            sampAddChatMessage("Руда найдена на расстоянии: " .. tostring(playerDistance), -1)
            
            if not isPlayerNearObject(object, 5) then
                if playerDistance > 1 then
                    sampAddChatMessage("Нашел руду, рядом игроков нет, бежим туда.", -1)
                    taskGoToCoordAnyMeans(PLAYER_PED, objectPos.x, objectPos.y, objectPos.z, 6, nil)
                else
                    sampAddChatMessage("Достиг руды, начинаю копать!.", -1)
                    taskStandStill(PLAYER_PED, -1)
                    sendkey(1024)
                end
            else
                sampAddChatMessage("Игроки рядом с рудой. Игнорируем.", -1)
            end
        else
            sampAddChatMessage("Руда не найдена в радиусе.", -1)
        end
    end)

    while true do
        wait(0)
    end
end
```
Стек переполняется после сообщения: Игрок в позиции: table: 0x03e78dd0