Loop through modules getting error instead of nil

Hello, recently i’ve got a data issue when saving modules information into data, the problem is when I make an in pairs loop through out the module, I made it search for the item’s rarity and which rarity it has but when the item isnt in any rarity that is being searched on the module it doesn’t gives nil and instead we get an error.

We are trying to check if an index is inside another index or if they are not. It gives nil but it stops running instead of returning to nil.

This is the part of the script that is generating error
local newtab = {}
for i,v in pairs(knifeskinsDataStore:Get(DefaultSkins)) do
for sk, b in pairs (SkinsModule[“KnifeSkins”]) do
if v == “0” then
else
if sk[“Common”][v] == nil or sk[“Rare”][v] == nil or sk[“Epic”][v] == nil then
else
table.insert(newtab, v)
KnifeSkins.Value = KnifeSkins.Value…" ; "…v
end
end
end
end

v is the item name that we’re trying search in module, but we need to get the rarity index before the item. I’m asking for help because my team and I have been stopped by this problem and i can’t figure out a way to fix it. Feel free to ask any questions if i did not make it clear.

In the first for you use i,v and i is the key, v is the value (name)
In the second for you use sk,b where sk would be the key and b the value
in the if sk you are treating sk as an array but its a key.

No, Im treating sk as an index, theres an index inside the index.

Is Crimson in a different tier level?

Crimson is inside on his rarity, but it get a error when the loop get the wrong rarity instead of making it nil

Shouldn’t you use “and” instead of “or”? Or not… I apologize it’s hard for me to understand the code a bit due the naming. It may seem unnecessary, but it can help to name your variables such as i, v, sk, and b into something more appropriate to the actual purpose/object.