I know that using workspace
instead of game.Workspace
is deprecated, but is there anything wrong with using it?
workspace
is not deprecated.
Oh really. I thought I’ve seen an error when hovering above it saying just that. Weird.
The capitalized W version (Workspace) is deprecated though.
Oh alright, but is there anything bad with using it? Not that I have any use of it, but is it lacking any functionality?
I’m pretty sure no, the reason is probably because globals are supposed to be lower case. Not sure though, I did some benchmarking on both but they seem the same.
Roblox, at some point, changed their naming conventions. However, they can’t drop the old ones entirely for the sake of backwards-compatibility, so they had to keep them. You don’t lose any functionality by using the deprecated ones, but you really should use the normal ones.
Alright, was just wondering. I use game.Workspace
anyway. Thanks for letting me know.
It’s better practice to use game:GetService("Workspace")
instead of game.Workspace
because if Workspace was renamed to something else it would throw an error since game.Workspace
would not exist.
game:GetService("Workspace")
would also error if Workspace was renamed, stating that 'Workspace' is not a valid Service name
. Generally you do not need to use :GetService if you are certain the service will already exist.
I doubt they would ever change something like that.
There must be a difference though, since I heard its better practice to use game:GetService()
GetService is mainly used for services that aren’t guaranteed to be instantiated
Except, this is not the case because GetService
uses the ClassName
of the services and not the Name
of them. This is why GetService
calls like game:GetService("RunService")
works even though RunService
is named “Run Service” when created.
I had completely forgotten about RunService!
Even still, the entire RunService thing is due to backwards compatibility. Roblox is obsessed with backwards compatibility. Any game (that was made after they forced Filtering Enabled) is effectively guaranteed to work with all future versions of Roblox.
Changing the Workspace name would break a lot of scripts that don’t use GetService to get the Workspace because the Workspace name has been unchanged from the beginning.
This Roblox blog from 2012 shows Roblox Studio 2.0, and with it, the Workspace.
What about any Roblox games that are made before they forced FE into Roblox? (old games) Do these games broke with FE or are they backward compatible with FE?