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

What does :GetService() do exactly in code?

What does game:GetService() do. Ive read that :GetService() gets a service just like its name but I never understood how it works. I used it in

https://education.roblox.com/en-us/resources/intro-to-coding-coding-3-creating-a-point-giving-part

to make the point giving Part but when I removed it the code still works normally. Can someone explain to me what It does and give some examples? Thank You

1 comment

0

Well, on the client, if your trying to use UserInputService i believe you have to use GetService. If you do game.UserInputService you get the UserInputService is not a valid member of DataModel error

1 answer

✓ Accepted answer

game:GetService("Workspace") are basically the same as game.Workspace, but some service cannot use that way (game.Workspace) most script-er recommended using game:GetService() except for workspace.

local Workspace = game:GetService("Workspace") -- is the same as
local workspace = game.Workspace

Hope my badly made answer helped

1 comment

0

Helped a lot Thanks

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