Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I get a value from a table in a certain order?

Asked by 5 years ago
Edited 5 years ago

This is what I have so far, I assume it's pretty clear what my goal is. I am trying to make a table that holds all the items for sale, though when run my current script it errors out?

-- Local Script
local ITEM_LIST = {
    [1] = "Item1","Top Test", "Desc Test";
    [2] = "Item2","Top Test 2", "Desc Test 2";
}

for i,v in pairs(ITEM_LIST) do
    local template = script.Template:Clone()
    template.Parent = MAIN_FRAME.ItemFrame
    template.ItemName.Text = v[2]
    template.Name = v[1]
    template.ItemDesc.Text = v[3]
end

Error:


-- Error (Line 47 is line 10 in the script above) 11:36:36.804 - Players.Pizzafireme.PlayerGui.Gui.Main:47: bad argument #3 to 'Text' (string expected, got nil)

Any help and an explanation on what I'm doing wrong would be much appreciated, thanks!

1 answer

Log in to vote
1
Answered by 5 years ago

you define 1 and 2 but you are using 2 and 3, 3 does not exist

Ad

Answer this question