I've been trying this for a while.
So I have a table that looks like this:
{"ITEM1","ITEM2"}
I'm attempting to one of these values but I am not sure how I should go about it. Any help?
I've been trying this for a while.
So I have a table that looks like this:
{"ITEM1","ITEM2"}
I'm attempting to one of these values but I am not sure how I should go about it. Any help?
The code example you provided is an array table, the index would be 1 and 2 (sequential integers). If you want to find out if a value is in the table you'll need to iterate the table and compare the values to the one you're looking for.
local t = {"ITEM1", "ITEM2"}
for index, value in ipairs(t) do
if value == "ITEM2" then -- let's say I want to find "ITEM2"
print(value .. " found at index " .. index)
return index
end
end
This discussion is preserved as it was. New answers, comments, and votes are closed.
4 comments
use a array
it is an array, that's the json decoded string.
json decode will return a dictionary, you can iterate/index them by following wiki https://www.robloxdev.com/articles/Table#iteration
arrays or loops will work... table[1] = "ITEM1" table[2] = "ITEM2"