How to get a specific "key" or "index" from a table?

Thanks to the help of Dracolyx and TerryMichaelBrunk, I was able to find a solution… in the meantime of waiting for him to update his solution, Here’s mine!

Clean Version:

local num = 1

local Table = {
	{Lobby = "ChangeToAny", v = "2"};
	{House = "b", v = "Taco"};
	{Mansion = "yo", Mansion = "yo", v = "Parties"};
}

for i, v in pairs(Table) do
	print(i, next(Table[num]), Table[num].v)
	num = num + 1
end

Output:
image
With Quotes:

local num = 1

local Table = {
	{Lobby = "ChangeToAny", v = "2"};
	{House = "b", v = "Taco"};
	{Mansion = "yo", Mansion = "yo", v = "Parties"}; --[[ "yo", "b", and "ChangeToAny" can be called as a fourth variable with Table[num].VariableName ]]
}

for i, v in pairs(Table) do
	print(i --[[ Index number ]], next(Table[num])--[[ Key replacement ]], Table[num].v --[[ Value replacement]])
	num = num + 1
end

Warning: Some words that are called with next(Table[num]) are ignored and will return the next variable (v) instead of the original variable you want to call. To fix this simply double them up as shown with {Mansion = “yo”, mansion = “yo”…}.

4 Likes