You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
I am attempting to make a function that automatically creates my 100+ weapon UI boxes since I dont want to manually do it. It shows only a little bit of them in the module as a test.
- What is the issue? Include screenshots / videos if possible!
I get no error and it creates the buttons fine but they are not in order they were set in the module such as default sword being third and solar sword being first while the default sword is first inside the module.
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I thought it was a delay of the UI not loading in fast enough for the buttons but even I simply print out the names they are out of order. I cant find any answers.
here is my module
local Swords = {
["Default Sword"]={Gain=2,Price=0, Type = "Sword"},
["Fire Sword"]={Gain=3,Price=29, Type = "Sword"},
["Grass Sword"]={Gain=5,Price=50, Type = "Sword"},
["Bolt Sword"]={Gain=8,Price=87, Type = "Sword"},
["Doom Sword"]={Gain=13,Price=151, Type = "Sword"},
["Ocean Sword"]={Gain=21,Price=262, Type = "Sword"},
["Night Sword"]={Gain=34,Price=455, Type = "Sword"},
["Solar Sword"]={Gain=55,Price=789, Type = "Sword"},
["Shock Sword"]={Gain=89,Price=1369, Type = "Sword"},
["Thunder Sword"]={Gain=144,Price=2374, Type = "Sword"},
}
return Swords
here is my loop function. Note this is not the full code as my full UI script has 400+ lines of code but the variables for the module are correct.
for k,v in pairs(WeaponInfo) do
local Template = WeaponButtonTemplate:Clone()
Template.Parent = ShopUI.Main.WeaponScrollingShop
Template.Name = k
Template.Gain.Value = v.Gain
Template.Price.Value = v.Price
Template.WeaponType.Value = v.Type
end