When should i use GetService()

Shoud i use getservice everytime im accessing a service or no?

1 Like

Based on this reply from a similar post…

You should use :GetService() all the time, since services can be renamed by developers or scripts and will cause errors if not implemented correctly.

Sometimes you won’t have to if you never actually rename your services, but it’s a good practice to always use :GetService() just in case something happens.


I don’t see why i would need to rename my services. Other than that are there any actual uses for getservice?

GetService function can be used when you need to get special functions or units from a service, for example you need to press some key to play a function, you need to call userinput service, and when you want smooth part transition you would like to call tween service

You can get more infromation about services

The only thing I can think of would be possibly when working with a team of people, as preferences can vary (contributions to this list of examples is appreciated).

Personally, I tend to not rename my services (as I also see no point) and use game.<service>, but that’s really only because the games I do it on are solo projects.

Other than that, you should use :GetService() instead.

renaming services randomly during runtime is quite common for game security, as most script kiddies will just do .servicename rather than getservice, stops their exploits for a bit longer, enough time to detect and kick hopefully.

1 Like

GetService is used to retrieve specific game services e.g tweenservice runservice replicatedstorage etc. but even if you change for an example ReplicatedStorage’s name to RemoteStuff, doing game.ReplicatedStorage would throw an error, but game:GetService("ReplicatedStorage") wouldn’t. it doesn’t rely on reading instances by name.