Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

What is the Best SetCore method?

Asked by
LostPast 253 Moderation Voter
6 years ago
Edited 6 years ago

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

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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.

Ad
Log in to vote
1
Answered by 6 years ago

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.

0
No, you should use GetService for every script. User#19524 175 — 6y
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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

0
No, coding is not about what is shortest. It's more about efficiency. User#19524 175 — 6y

Answer this question