How do I got a certain table string by number

So basically, I had an idea of setting up game updates list using module scripts, but the problem is I cannot find out how to print it out, it returns nil

image

printing:

image

(gameupdates[1].Description doesn’t work aswell)

If you can help me, holler at me down in the replies

Dictionary keys are the strings you assign it to. To index that element, you’d have to do
[gamupdates["8-28-2021"] → {…}

1 Like

No, I will make it automatic, I want it to print out the first 5 strings, so I don’t have to bother a lot. that’s why I did [1]

That is because the key is not 1, it is [“8-28-2021”]. If you try printing gameupdates[“8-28-2021”], it will print the description.

If you wanted to order the updates so it shows the most recent it could be like:

local gameupdates = {
    {date = "8-28-2021",
     description = "2.0 Release!"},
    {date = "7-28-2021",
     description = "1.9 Release!"},

indexing 1 would give the most recent update

1 Like

So how do I print it out, the same way I did it?

for key, entry in next, gameupdates do
    print(key)
    print(value.Description)
end

For loops also work differently with dictionaries.

1 Like
for i =1, 5 do
    if gameupdates[i] then print(gameupdates[i]) end
end

also, change the date variable name since that is reserved, my bad I forgot.

2 Likes

I don’t think you understand what I’m trying to achieve, basically I did [1] so it gets the first string in the table, later on i will add 5 lists to add onto the gui which is the work i’ll do later

Ah, then @scripted_pj’s solution should work for you.

This works great, appreciate it