Roblox Getservice return a service with the class name requested. When called with the name of the service like Debris, this one will return the instance of that service. If the service does not yet exist, it will be made and the new one is returned. Apparently, this one is the only way to create some services, and can also be used for services that have unusual names such as RunService’s name is Run Service.
Please take a note that this function will return nil if the className parameter is the existing class, but the class is not the service. If you try to fetch the service that is present under another Object, there will be an error thrown stating that the singleton serviceName already exists.
In fact, most services are direct children of game. However, not all of them are and some spme pf them might not exist when your game is run. In this case, you have to use Roblox GetService in order to access those services. You are able to simplify down Roblox GetService and say it has two uses.
The first one is getting the hold of service when you are not able to access it through the game.ServiceName. For example, UserInputService is not the child of the game, so whenever you want to use it, you have to access it through game: GetService(“UserInputService”). If you want to access the lighting through the game, you can rename it to something other than “Lighting”. If the name of the service has been changed and your script does not know what the new name is, the only way you can access it is through Roblox GetService.
The second one is for loading services that are not currently loaded. For your information, the only services that are not loaded by default are TestService and Teams. In the TestService case, you have to use game:GetService (“TestService”) in order to create it. Aside from that, you also might have the service that somehow gets deleted and you have to re-create it.
You have to know that all the services are used often in scripting, from prompting the player to purchase items to reading input from the keyboard and mouse, so you have to make sure that you know how to use them all. In fact, you have probably already used some of them without knowing though. Apparently, workspace, lighting, and players are all services. In addition, invoking game.Players: GetPlayers () is using the service.
In conclusion, Roblox Getservice can be described as something you run when you want to get the service that cannot be accesses by the game. E.G game: Getservice (“MarketplaceService”) gets the Roblox “marketplace”. For those who are not familiar with the term “marketplace” it is the place where you buy stuff like clothing.
For more information about Roblox Getservice, please visit the official website of Roblox Developer. Wiki also can be the good source that you can try to visit. Aside from that, you are encouraged to visit Roblox community and discuss with all the members.