What is the difference between "workspace" and "game.workspace"?

  1. What do you want to achieve? I want to know which one should i use in my scripts. Should I use "workspace" or "game.workspace" if there is a difference?

  2. What is the issue? I do not know which one to use.

Which one should i use:

`local part = workspace.Part`

or

local part = game.Workspace.Part

I think that there isn’t a difference. But, still, which one should i use? or when should i use workspace and game.workspace ?

1 Like

There isn’t necessarily a difference. I saw a while back that apparently there is a very very tiny performance boost by using one over the other (or defining it as your own variable), but the difference is miniscule.
Personally, for readability I use workspace, but you may want to use game.Workspace to keep parity with other singleton references (game.Players, game.ReplicatedStorage, etc.)

1 Like

There is no different, except one is longer and uglier. The intended way to retrieve “services” is with :GetService, which means the alternative should be game:GetService("Workspace"). Just use workspace.

:frowning: game.SERVICE is blasphemy in this household…

3 Likes

The recommended ways to get workspace are workspace or game:GetService("Workspace"). Using game.Workspace is not recommended and the GetService method is recommended instead by Roblox.

It’s technically faster to use

local Workspace = game:GetService("Workspace")

because the Workspace variable is then local instead of a global variable, though really the difference isn’t very much. I prefer defining it locally though since it looks like other services.

Functionally, workspace and game.Workspace refer to the same variable, but the only difference is that game.Workspace searches through all the children of workspace, while workspace is just defined as the object in the first place. This means game.Workspace can fail if the names are changed, while the other methods will always work.

I read somewhere that developers typed game.workspace so often that a Roblox change it to just workspace to help the developers.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.