I am trying to get a random sub-table from the main table, then get it's info. Can anyone explain what I'm doing wrong here?
local songDatabase = {
['Light In Us All'] = {
audioId = 1513373015,
audioAuthor = 'You, Me & Gravity Album'
},
['Theories of an Eager Heart'] = {
audioId = 0,
audioAuthor = 'You, Me & Gravity Album'
},
['Breakfast of Champignons'] = {
audioId = 0,
audioAuthor = 'You, Me & Gravity Album'
},
['With Friendship & Peace'] = {
audioId = 0,
audioAuthor = 'You, Me & Gravity Album'
},
['Small Hands Make Big Things'] = {
audioId = 0,
audioAuthor = 'You, Me & Gravity Album'
},
['Dream. Build. Repeat.'] = {
audioId = 0,
audioAuthor = 'You, Me & Gravity Album'
},
['Aspect Imaginarium'] = {
audioId = 0,
audioAuthor = 'You, Me & Gravity Album'
},
['Clever Candles Steal the Light'] = {
audioId = 0,
audioAuthor = 'You, Me & Gravity Album'
},
['Sink Cat'] = {
audioId = 0,
audioAuthor = 'You, Me & Gravity Album'
},
['You\'ll Know When It Turns Invisible'] = {
audioId = 0,
audioAuthor = 'You, Me & Gravity Album'
},
['Theme Parks After Dark'] = {
audioId = 0,
audioAuthor = 'You, Me & Gravity Album'
},
['Things to Consider During Freefall'] = {
audioId = 0,
audioAuthor = 'You, Me & Gravity Album'
},
['You, Me & Gravity'] = {
audioId = 0,
audioAuthor = 'You, Me & Gravity Album'
},
['Pride of Pimlico'] = {
audioId = 0,
audioAuthor = 'You, Me & Gravity Album'
},
['Heisenberg\'s Entryway to Matrix Mechanics'] = {
audioId = 0,
audioAuthor = 'You, Me & Gravity Album'
},
['And so We See the Truth & the Beauty'] = {
audioId = 0,
audioAuthor = 'You, Me & Gravity Album'
},
}
local function pickSong()
local pickedSubTable= songDatabase[math.random(1,#songDatabase)]
local audioId = pickedSubTable.audioId
local audioAuthor = pickedSubTable.audioAuthor
end
wait(2)
pickSong()

1 comment
songDataBase is a dictionary, not an array, therefore using the length operator on it would be 0, as dictionaries do not have numbered indexes