So I've been looking at some scripts and they were using :GetService instead of doing game. , here are some examples:
--StarterGui game:GetService("StarterGui") game.StarterGui --RP game:GetService("ReplicatedStorage") game.ReplicatedStorage --Workspace game:GetService("Workspace") game.Workspace workspace --SS game:GetService("ServerStorage") game.ServerStorage
From what I know, you can do that for any child of game. Can someone please explain to me if there is any difference?
I recommend GetService
as some people like to change the name of their core services in game.
For example, some people would change ReplicatedStorage
to RepSto
. Then, if you try to use game.ReplicatedStorage
it wouldn't work, because it looks for the name, not the service. On the other hand, if you do game:GetService("ReplicatedStorage")
, even if the name is RepSto
, it will look for the service associated with the class.
But, if you don't change your game services' names, you can do game.ServiceName
.
All in all, I recommend getting into the habit of using game:GetService("Service Name")
.
Hope this cleared things up and helped you!