Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

What is the difference between finding a child of game normally and using :GetService?

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?

1 answer

✓ Accepted answer

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!

2 comments

0

Thanks. I didn't even know you can change the name of core services.

1

No problem! Glad to be of help! We always learn something new everyday!

This discussion is preserved as it was. New answers, comments, and votes are closed.