Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

What is the Best SetCore method?

Out of these four methods to Set a Core UI value to false which one is the best? What are the key gains and losses of choosing one method over the others?

game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
game.StarterGui:SetCoreGuiEnabled("BackPack", false)
game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
game:GetService("StarterGui"):SetCoreGuiEnabled("BackPack", false)

Thanks!

3 answers

✓ Accepted answer

###The third one is best. You should always get your services via GetService (Workspace gets a pass because of the game property and global variable). Accessing a service via game.Service is prone to script error, should the desired service be renamed.

These methods are basically the same, but in my opinion you should go with line 1. GetService is unnecessary for services that are already there and if you're using a server script, using GetService in local scripts is typically what everyone does because sometimes the local script fires before the services load up and it can cause errors.

Typically when you use Enum over Strings it's more efficient and faster and a lot easier to edit values than having to figure out what things are called.

Just remember to always use Enum over strings, it's faster and more efficient.

1 comment

0

No, you should use GetService for every script.

They seem to be the exact same, so I would choose the second option (it's the shortest one).

1 comment

0

No, coding is not about what is shortest. It's more about efficiency.

This discussion is preserved as it was. New answers, comments, and votes are closed.