I’m working on a rarity system for my inventory system right now, i’m wondering what is more efficient to do;
Having a button in a folder for every rarity, cloning it and only changing the name
Or simply creating a button, and in script, change all the textures.
Of course you’d want to use a script. Adding/removing/updating buttons is just needlessly harder without automation. So make a template button and clone it via a LocalScript, use a UIGridLayout or UIListLayout depending on your goals.
Not too sure about that, but doing one operation over multiple lines of code seems more efficient and organized on the surface. Not to mention it would be less practical when you want to update that template through code rather than visually.
Personally I think the pros in cloning outweigh the cons, but how you do it is up to you.
Depends on how you want to do it. I like to keep everything generic myself, so I would do a button for each. However, if many of the options have different texture options… That could be done generically also. Guess it comes down to how many different textures the items have and if many have different textures for me. Having one set up that is repeated for every items the same way is all I would really care about. You can do things about any way you want with a few items, but when you start getting many you’ll be glad you stick to being generic.
So i’m still unsure whether I should clone() or instance.new() with my situation,
If I have a button as shown in the image, is it better to create that template using instance.new() or just clone() it? with the amount of children in the button i’m not sure which is less resource intensive
It doesn’t matter if you doing it once. To see the difference you would hvae to create them millions in few seconds. In your case you should use Clone().
I suppose I just like to try get the most out of optimization, Ill use clone(), but there can be upwards of 100 clones created when a player loads depending on the inventory