I have a shop system which orders each item by the item name, and I want to sort the item name based on the cost, so the further down the shop you go, the more expensive the items are.
The value named 1 has a cost of 50, and the value named 2 has a cost of 20, how would I make it so the values get ordered by cost, so value 1 becomes value 2 ansd so on?
Not sure what you are intending. If you are wanting to use the sort by name property on UIListLayout, you could also use the LayoutOrder property and just set that property to the cost. Itβll sort itself.
But Iβm not sure if you are using GUIs. Can you please provide more information?
The values are in replicated storage, and a local script automatically creates frames in a gui that are listed based on their names, however, some items have higher costs than others, but since their names are smaller than others, they get listed at the top of the list, I want to make a script that renames the values based on price, so the most expensive items are at the bottom of the list in the gui.
Assuming your UI that holds all the items has a UIListLayout of some sort.
for _, item in pairs(Guns:GetChildren()) do
local Cost = item.Cost
local Frame = template:Clone()
Frame.Name = item:FindFirstChild("Name").Value
Frame.LayoutOrder = Cost.Value
Frame.Parent = ItemHolderFrame
end
Nevermind, I managed to make a script of my own which loops through each item in the folder, then puts the price of the item in a table. Then I used table.sort to sort the prices from lowest to highest and then looped through each item and renamed the items by finding their price in the table and changing the name to the index of the price. Thanks everyone for your help!