Game.{service} versus game:GetService("{service}")

Whats the difference for using for example, game.ReplicatedStorage versus game:GetService("ReplicatedStorage") ?

Is one somehow faster than the other or more reliable? Thanks for any reply.

game.ReplicatedStorage accesses the service through its Name property, while game:GetService("ReplicatedStorage") accesses the service through its ClassName property. GetService is more reliable since services’ names can be changed, and if you are using the first option, the script will error. Some services have by default different names than they should, such as RunService being named as Run Service (notice the space between the words) or UserInputService and other services being named as Instance. GetService also creates the service if it isn’t already there, such as the Teams service or ReplicatedScriptService.

5 Likes

For stuff in explorer I find it easier to just use stuff like game.ServerScriptService instead of game:GetService("ServerScriptService"), but other stuff I couldn’t tell you one person who uses game["Run Service"] instead of game:GetService("RunService"). I dont think stuff like game.TweenService even exists if I’m correct.

Thanks for the answer @TheTravellerChicken1, it’s very straightforward and clear!

1 Like