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

When should you use GetService() and how should you write it?

Asked by 5 years ago

I understand how GetService() works, and I know that in some cases it is required to use it, if for example the service has not yet been created, but is there any benefit in writing :

local ws = game:GetService("Workspace")

Over Just :

local ws = game.Workspace

Is it more efficient? Less efficient? And I'm also curious about the way that you write these types of things. I've heard that this is better :

local ws = game("GetService", "Workspace")
local Part = ws("WaitForChild", "Part")

And this is slower :

local ws = game:GetService("Workspace")
local Part = ws:WaitForChild("Part")

Answer this question