Workspace vs. game:GetService("Workspace")... Which one to use?

Hello! I am wondering which one to use.

for i, v in pairs(workspace:GetChildren()) do
 print(v)
end
for i, v in pairs(game:GetService("Workspace"):GetChildren()) do
 print(v)
end

Note: This is an example, and I will not be using this code.

Which one is more reliable and recommended for the game.

If you have an answer, please let me know. Thanks! WE

They are both the same, but I always use workspace instead of game:GetService("Workspace")

1 Like

workspace is a reference to the Workspace service, so they both are basically the same thing, so I don’t really see a use in getting the Workspace service yourself when workspace is shorter and does the same thing, and it also looks a bit cleaner imo

2 Likes

Both are exactly the same(the workspace instance always exists, why else wouldn’t it be?), only difference is the preference of each scripter. One may be more popular than the other but it does not mean the other method is completely obsolete.

2 Likes

It’s really up to the person coding to decide that… I always use workspace because it’s just easier to type and poses no real performance issues.

2 Likes

workspace is easier and with :GetService(“Workspace”) you can sometimes confuse yourself when making longer scripts.

1 Like

All the same.
Use whichever you prefer to.
I personally use game.Workspace

Because it’s a service, for organization and consistency I’d always localize WorkspaceService as game:GetService("Workspace"), just like I’d localize all the other services, but for optimization I’d suggest workspace is faster since it’s built in.

After testing the time it takes to complete ~1000 loops of indexing workspace over :GetService() showed that the performance is almost undetectable. Use whatever is more comfortable and easy to read.

If you localize both, which you should be doing for frequently indexed services anyways, it’s negligible.


This is entirely preference. Some say that you should use GetService for everything for consistency, and I likely would for anything substantial/open-source, but workspace is fine for the most part. I don’t think either is any clearer or less clear.

3 Likes