Get distance from marker where co-ords are in an Array

Sorry, I reinstall my computer and I didn’t reinstall fiveM

‘ply’, ‘plyCoords’ and ‘distance’ have to be inside your while loop.

Is “EUP Client Trigger Created” printed?

If it’s the case, try to print the calculated distance in the while loop and use a float to compare it (5.0 not 5).

For, player coords, use this:

local pedX, pedY, pedZ = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))

I made some changes and it works for me:

local maxDistance = 15.0
local interactDistance = 3.0
local markersTable = {
    { X = -447.44305419922, Y = 6007.9516601563,    Z = 31.716375350952 },
    { X = -448.53857421875, Y = 6009.2690429688,    Z = 31.716375350952 },
    { X = 1848.2177734375,  Y = 3689.5593261719,    Z = 34.267040252686 },
    { X = 369.9228515625,    Y = -1607.12976074219, Z = 29.291934967041 },
    { X = 1003.63, Y = 2367.9, Z = 51.73 }
}

Citizen.CreateThread(function()
    while true do
        local pedX, pedY, pedZ = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
        for k, _ in pairs(markersTable) do
            local distance = Vdist(pedX, pedY, pedZ, markersTable[k].X, markersTable[k].Y, markersTable[k].Z)
            if distance <= maxDistance then
                DrawMarker(1, markersTable[k].X, markersTable[k].Y, markersTable[k].Z - 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 255, 0, 0, 255, 0, 0, 0, 0, nil, nil, 0)
                if distance <= interactDistance then
                    SetNotificationTextEntry("STRING")
                    AddTextComponentString("<b>Press E To Open The EUP Menu</b>")
                    DrawNotification(true, false)
                    if IsControlJustPressed(1, 38) then -- E
                        print("E pressed")
                    end
                end
            end
        end
        Citizen.Wait(0)
    end
end)

Weird.

I put your version in my script and nothing.
I then moved to another resource that I made to test and yet again nothing.

This is the only thing in the resource client.lua

local maxDistance = 15.0
local interactDistance = 3.0
local markersTable = {
    { X = -447.44305419922, Y = 6007.9516601563,    Z = 31.716375350952 },
    { X = -448.53857421875, Y = 6009.2690429688,    Z = 31.716375350952 },
    { X = 1848.2177734375,  Y = 3689.5593261719,    Z = 34.267040252686 },
    { X = 369.9228515625,    Y = -1607.12976074219, Z = 29.291934967041 },
    { X = 1003.63, Y = 2367.9, Z = 51.73 }
}

Citizen.CreateThread(function()
    while true do
        local pedX, pedY, pedZ = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
        for k, _ in pairs(markersTable) do
            local distance = Vdist(pedX, pedY, pedZ, markersTable[k].X, markersTable[k].Y, markersTable[k].Z)
            if distance <= maxDistance then
                DrawMarker(1, markersTable[k].X, markersTable[k].Y, markersTable[k].Z - 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 255, 0, 0, 255, 0, 0, 0, 0, nil, nil, 0)
                if distance <= interactDistance then
                    SetNotificationTextEntry("STRING")
                    AddTextComponentString("<b>Press E To Open The EUP Menu</b>")
                    DrawNotification(true, false)
                    if IsControlJustPressed(1, 38) then -- E
                        print("E pressed")
                        --mainMenu:Visible(not mainMenu:Visible())
                    end
                end
            end
        end
        Citizen.Wait(0)
    end
end)

Are you sure about the positions? It’s working for me.

Otherwise, try to clear the cache