I know this is a bad question, but there is something better at game:GetService(“Workspace”) than workspace?
I’m using a Local Script btw and the workplace may not be loaded.
I know this is a bad question, but there is something better at game:GetService(“Workspace”) than workspace?
I’m using a Local Script btw and the workplace may not be loaded.
I don’t use get service for anything unless its not in the explorer.
Possibly try game:WaitForChild(“Workspace”).
Good advice, but I think the workspace is always loaded (The instance, not the instances from it). Is it true?
Correct me if Im wrong but
workspace will instantly ‘return’ workspace
while doing game.Workspace
will go to game, then look up workspace, then return.
So just doing workspace should be fastest.
That is not what I said, I said if saying workspace can return nil if the game.Workspace is not loaded yet?
And, saying workspace is the same thing as game.Workspace
GetService should add it in if it doesn’t exist, so that’s still your best bet, not sure why you’re seeking another way.
I’d say you should use GetService, If it hasn’t loaded yet I believe it would load it for you as opposed to waiting for it to load, plus if you have a script that changes the names of services it would still be able to access them
Neither would be nil, ever. Workspace itself will always be loaded in by the time a script is able to run, even if its descendants aren’t.
agree with @posatta, never in my 10+ years on roblox has a script run before workspace was loaded.
It’s not exactly the same though. One points straight to workspace, another points to game and then look up it’s child: workspace.
If you’re super over-the-top about consistency (not necessarily a bad thing), then GetService
should be used for all service-level access/references. I know there are some devs here that care about this consistency, and it shouldn’t be seen as a negative.
Personally, I use the workspace
global usually.
As others have mentioned, you won’t run into the workspace not being loaded. The only time you will run into such issues is with data that replicates after initial load (e.g. stuff in PlayerGui, since it’s replicated from StarterGui after the player has loaded into the game).