Get index of an element in a dictionary?

So, if i had a table like the following:

local playerTable = {Player1 = 59, Player2 = 25, Player3 = 72}
for index, value in pairs(playerTable) do
    print(index) -- prints Player1, Player2, or Player3
end

When I print the index, I dont get a number, I get the PlayerName. I want the number of the element in the table, if that makes sense. Any help would be appreciated! :heart:

to do this in a dictionary, you would have to do something like

local playerTable = {Player1 = 59, Player2 = 25, Player3 = 72}
local currentIndex = 0
for index, value in pairs(playerTable) do
    currentIndex += 1
    print(currentIndex)
end
2 Likes

o ya, I thought that there would be something more complex, but this will work!