Hey guys, As you can probably tell from the title, this following code keeps telling me I'm comparing a nil value to a number.
Here is the code:
local hs = game:GetService("HttpService") local got_table = hs:GetAsync("https://search.rprxy.xyz/catalog/json?CatalogContext=1&Subcategory=2&SortAggregation=5&PageNumber=1&LegendExpanded=true&Category=2", true) local json_table = hs:JSONDecode(got_table) local dic_values = 0; local common = {} -- 0 and 2,500 local uncommon = {} -- 2500 and 9,000 local rare = {} -- 9000 and 75,000 local legendary = {} -- 75000 and 500,000 local ultra_rare = {} -- 500,000 and 999,999,999,999 for i = 1, 44 do print("Page #"..i..":") repeat for index,value in next, json_table do -- Counts the amount of values in the dictionary. dic_values = dic_values + 1; end got_table = hs:GetAsync("https://search.rprxy.xyz/catalog/json?CatalogContext=1&Subcategory=2&SortAggregation=5&PageNumber=" .. i .. "&LegendExpanded=true&Category=2", true) json_table = hs:JSONDecode(got_table) until dic_values > 0 for index, value in next, json_table do -- Prints all the values inside dictionary. if ((tonumber(value.BestPrice) or tonumber(value.Price)) >= 0 and (tonumber(value.BestPrice) or tonumber(value.Price)) <= 2500) then print(tonumber(value.BestPrice)) end end end print("Values are done!")
Apparently, the first part of the if statement on line #25, which is:
if ((tonumber(value.BestPrice) or tonumber(value.Price))
is giving me a nil value. I have no clue as to how that is happening because, I am using ternary and an object in catalog can't be missing both a BestPrice
and a Price
. So, if the first value is nil, it should just go to the next value.
Any help is appreciated and thank you, once again.
~~ KingLoneCat
here it looks like you have an extra parenthesis. I'm not sure though so do not downvote this,
(tonumber(value.BestPrice) or tonumber(value.Price)) <= 2500)