How to get only the first value in an api

Im using the rolimons api to get all the playerAssets from the roblox account though the problem is the api works like this

"playerAssets": {
    "1028606": [28605],
    "1028720": [28994],
    "1029025": [30169, 8835350],
    "1031429": [34466],
    "1032641": [36365, 7786554196],

Now i only want to get the first value not the value in the brackets how would i do that?

api: https://api.rolimons.com/players/v1/playerassets/1

You will need to change how the values are displayed.

If you are trying to get 1028606 without 28605, you would do the following:

local newAssets = {}
for id,_ in pairs(playerAssets) do
   table.insert(newAssets,tonumber(id)) -- Add the id as a number into the table
end
print(newAssets) --> {1028606,1028720,1029025,1031429,1032641}

I am using 3 spaces in this code for tabs. You may need to convert it to tab characters in your editor.

You must sort your table if you want the lowest/highest value. The API may not ensure the order.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.