You could use for the markers:
local markers = {
{ -- marker data
otherProp = '????',
element = '<marker element>'
},
{ -- marker data
otherProp = '????',
element = '<marker element>'
},
}
Loops are not needed if you use the `player` as key.
And as for the players and their data:
---@type {[userdata]: {[string]: any}}
local playerData = {}
--- Give a player their own table/data
---@param player userdata
function initPlayerData(player)
if playerData[player] then return end
playerData[player] = {} -- < sub table
end
---@param player userdata
---@param key string
---@param data any
function setPlayerData(player, key, data)
if not playerData[player] then return end
playerData[player][key] = data
end
---@param player userdata
---@param key string
---@return unknown|nil
function getPlayerData(player, key)
if not playerData[player] then return end
return playerData[player][key]
end
Usage example:
--- SET
setPlayerData(player, "nextMarker", marker)
--- GET
local marker = getPlayerData(player, "nextMarker")