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

What is GetService() and how can i use it?

YT can't tell it and i don't know how to use it so i need some suggestion

1 comment

0

Use the Wiki. Youtube probably does not cover every function (and if it does, it is probably hard to find some functions), but the wiki does. If the wiki deletes a page on something, then you can probably use Youtube. If you can't find it there, it probably doesn't exist and never existed.

2 answers

game:GetService(Service) is used to obtain the requested service. Unlike indexing the given service with dot notation (e.g game.ServerStorage), the GetService method allows you to find services with unusual names. For example, the Run Service service would have to be indexed like this: game["Run Service"]. However, by using GetService, this code can be reduced to game:GetService("RunService") (notice how the whitespace is avoided).

Here's the wiki link

game:GetService("ServiceName") is a command to find Services in the game, so you can use them for certain things.

For e.g:

If you type in for example "Instance.new("Team", game.Teams)" when there are no teams, the output will through out an error saying that there's no such thing as "game.Teams". If you do this instead: "Instance.new("Team", game:GetService("Teams"))", it'll create a team in game.Teams without any errors.

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