What's faster: Copying a template and making edits, or creating from scratch

I want to know what is quicker in terms of creating a bunch of buttons quickly. I have a customise system, which will inevitably contain thousands of buttons, and all these buttons need to be created on start up. Problem I face is if a player opens the customise while buttons are still being created, then you can see the buttons being added.

Currently, I create each button individually via code (creating the button, icon, etc. setting sizes/colors, etc.) So I want to know if it would be quicker to create a template in studio, and then just clone that and make small edits to it (changing the name of the clone + icon) would this be quicker? Or is there no difference in speed

Theoretically, a premade template would be a little faster since it’s already made, and less updates would need to be made. I wouldn’t worry too much about that though, since usually the difference is very negligible

3 Likes

I figure that would be the case. I don’t want to change my code for a miniscule time difference tho. Have to bear in mind tho, the code is having to create thousands of buttons, so it takes quite a bit of time already :weary:

1 Like

I’d personally go with the template because it’s easier for me to work with; I like having the visual and having less code to write.

I’d say that speed isn’t worth worrying about here and instead you should think more about the context of your code. I prefer templating in scenarios where I desire consistency across sessions but will instance from scratch if that’s part of the requirements. Either way though, I typically end up templating at a bare minimum level. I never fully create from scratch, templating is always present in some form.

For example:

Templating → Cloning a data structure and then modifying it according to saved data as opposed to using the saved data as my data structure. If I make changes, people will have inconsistencies. Simply joining will fix it because the blanks will be added naturally.

Instancing → Needing to create arbitrary spaces around certain objects with respect to their sizes and positions, such as a zone indicator. This is in a scenario where dynamic indication would be needed, since zones can be thought of as static.

For your case, I think you’d love to create a template. You’ll have a few negligible bytes of data being consumed by nature of the instance existing in the DataModel, but it’d be much easier to make uniform edits by modifying a template and not your code.

In either scenario, players will still see all the buttons being gradually added. In this case, you can create artificial loading or delay indicators for the player to tell them that options are loading when in reality you’re taking the time to populate the Gui with options. That’s acceptable. If you’ve ever tried scrolling through your Roblox inventory, you’ll notice that pages don’t load instantly. The arrow button goes gray and there’s a delay, anywhere from a few miliseconds to around 2 seconds. When the page turns, all the elements have been populated.

Can’t you just disable the customise button until it’s ready?