local preferredPaths = {} local function convert(route) local notPreferred = route:FindFirstChild("NotPreferred") if notPreferred ~= nil then return 0 else return 1 end end local function sortByPreferred(path, route) table.insert(preferredPaths, ([path] = route,) --this gives a red line table.sort(preferredPaths, function(a, b) local ca, cb = convert(a), convert(b) return (cb < ca) end) return preferredPaths[1] end
Correct me if I'm wrong, but I didn't bother explaining what the parameters mean. I think I should just put out there that I want the path and the route to be paired together in the table preferredPaths, so that I can sort the table based on whether or not a child named "NotPreferred" belongs to the route. You could tell me how to add the pair of values to my dictionary, or just tell me how to do everything if you're feeling generous. Thanks!
just create a value just like how you would index one, and set the index and value of it
ex
local dictionary = {} dictionary["newValue"] = false -- or dictionary.newValue = false