I’ll just get right to the point, so I’m firing a function to compare 2 different tables for the purpose of checking if they are the same. Although for some reason it returns “nil” instead of the correct response.
local function CheckForLatestTable(OldDataTable)
for I, V in pairs(PlrDataTable) do
-- Checks if the category exists on the old table
if not OldDataTable[I] then
return false -- Plr has an old table
else
for i, v in pairs(V) do
-- Checks if the item exists on the old table
if not OldDataTable[i] then
return false
else
return true
end
end
end
end
end
“PlrDataTable” and “OldDataTable” are similar, this function is to determine if the “OldDataTable” has gone out of date (aka new items wered added to the game) by comparing it to the new “PlrDataTable”.
The “PlrDataTable” looks something like this, it has the main table, followed by Categories, and finally the actual items. I’m trying to make sure that “OldDataTable” has ALL of these categories and items within it. If the tables are the same, it should print true, else it should be printing false but instead it prints “nil”.
local PlrDataTable = {
Helmets = {
BlueHelmet = false,
GreenHelmet = false,
RedHelmet = false
},
Armour = {}, -- These tables will also have items in them
Clothing = {}, --
Tools = {} --
}
Any help is greatly appreciated.