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!
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.
They seem to be the exact same, so I would choose the second option (it's the shortest one).