Every time I add an array in this loop, it goes somewhere random in the table. I want it to be put at the end of my table.
Here’s my code:
local objects_used = {}
local objects = game.ReplicatedStorage.Objects
for i = 0, #objects:GetChildren(), 1 do
local lowest_price = 9999999999999999999999999999 -- just to start off
for i, v in pairs(objects:GetChildren()) do
local price = v.Information.Price.Value -- the cost of the item
if not table.find(objects_used, v.Name) then -- if its not in the table yet
if price <= lowest_price then -- if its cheaper than the cheapest
pricing = v.Information.Price.Value -- set cheapest to its price
table.insert(objects_used, objects_used[#objects_used + 1], v.Name) -- insert it to the table
end
end
end
end
end
I need them to be organized from cheapest to most expensive and i’ve tried it by using this method when inserting:
objects_used[#objects_used + 1]
which is on line
But it keeps saying that it’s nil