of     1   

Craftero
#183663250Monday, February 15, 2016 1:05 PM GMT

How do you find what position a given element of Table is? So, for example, lets say we know the string "Builderman" is in our Table. How do we find out where "Builderman" is positioned in that Table? Table[1], Table[2], etc. ? Do you have to iterate through the whole Table and increase a variable by 1 every time? I'm not really sure how to do this most efficiently. Any help or advise would be greatly appreciated.
cheesecake123456
#183663377Monday, February 15, 2016 1:10 PM GMT

Using pairs will give you an index and value of the table: for index, value in pairs(Table) do if value == 'Builderman' then print(index) end end
ElectoStriking
#183663473Monday, February 15, 2016 1:12 PM GMT

local t funciton checkTable(table,search) for i,v in pairs (table) do if sting.lower(search) == string.lower(v) then t = i return t end end end checkTable(Table,"Builderman") print (Table[t]) #Strikin'
ElectoStriking
#183663485Monday, February 15, 2016 1:13 PM GMT

actually im probably wrong #Strikin'
Craftero
#183663537Monday, February 15, 2016 1:15 PM GMT

@cheesecake123456 Thanks for the suggestion. I was wondering, though. If a value is added to that Table, does the Table get rearranged? Is the Table automatically rearranged in chronological order, so to speak, or is it ordered alphabetically?
cheesecake123456
#183663589Monday, February 15, 2016 1:16 PM GMT

The table is in a set order based on index, however pairs doesn't always go through in chronological order. If you need that, this should work: for i = 1, #Table do v = Table[i] if v == 'Builderman' then print(i) end end
AbstractMadness
#183668826Monday, February 15, 2016 3:09 PM GMT

function FindIndex(value, tbl) for i,v in next, tbl do if v == value then return i end end return value.." is not in the table." end local table = {1, 2, "Builderman", "LOL!"} print(FindIndex("LOL!", table)) > 3 #code R+ | local RAP = "421,538"; local robux = "R$14,980"

    of     1