Hey, i have a problem with simulator shop when i make a for loop that loops trough every tool in replicated storage and make a clone of a button for each tool into the shop Gui , everything works well except for the fact that some tools loads before the others that sometimes makes the expensive tools at the beginning some times bottom, middle ,etc…
Is there a way to fix that? i tried waiting for children of tool folder to fully load in but the problem still happens.
Yes you need to sort them.
For example I have this table of tools:
local YourUI = "something"
local Table = {
["Tool1"] = {Multi = 30},
["Tool2"] = {Multi = 10},
["Tool3"] = {Multi = 50},
}
local CopyArray = {}
for i, v in pairs(Table) do
table.insert(CopyArray,v["Multi"])
end
table.sort(Table,function(a, b)
if a < b then
return a
end
end)
for i, v in ipairs(CopyArray) do
YourUI.LayoutOrder = i
end