Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago

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

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. hiimgoodpack 2009 — 6y

2 answers

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

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

Ad
Log in to vote
0
Answered by 6 years ago

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.

Answer this question