use a loop, firstly make a table in all the positions:
pos = {
--{x,y,z}
}
for i,v in ipairs(pos) do
local x,y,z = unpack(pos[i])
createMarker(x,y,z ......)
end
closestMarker = 9999999999999999
addEventHandler("onMarkerHit",root,
function (player)
for i,v in ipairs(pos) do
local x,y,z = unpack(pos)
x1 , y1,z1 = getElementPosition(player)
distance2 = getDistanceBetweenPoints3D(x,y,z,x1,y1,z1)
--tell me what do you want then?
end
end
)