Loop is being weird

I’m not sure if it the loop or me or the script itself; however it isn’t working as intended.

for _,v in pairs(PadInTable.Players) do
	if v.Name == Player.Name then
		print("found")
	 end
end				
for _,v in pairs(PadInTable.Players) do
	print(v)
end

To explain things, PadInTable is a table that contains data (Tables, values…). One of the data is a table that is named “Players”. This table contains some players’ names.
Now, the script seems good and working however not as intended.
If you run that part, it doesn’t print “Found” but prints the player’s name in the second loop. (One player, which is me.)
image
The Player value is obvious, it’s the Player’s name.
Any suggestions would be helpful. Good day ladies and gentlemen.:tophat:

If you said you had a table inside of the table full of player names, you may have to loop through the original table, then if the key found is a table, you loop through that table.

If I’m not mistaken, your output is supposed to be a table name or whatever they call those long numbers, etc.

Maybe something like:

for _, v in pairs(PadInTable.Players) do
 if v:IsA("Table") then
  for _, v2 in pairs(v) do
 --- blah blah blah

not writing complete code cause im in school, but something along the lines of that I believe.

1 Like

One problem, “Table” isn’t in the data of “IsA”.
image

fixed, i wrote code in a lua compiler

local table = { 
    {"stuff", '2'},
    {"morestuff", '2'}
}

for _, v in pairs(table) do
    if type(v)=="table" then
        for _, v2 in pairs(v) do
            print(v2)
        end
    end
end

output:

stuff
2

morestuff
2

2 Likes