ServiceProvider
ServiceProvider : Instance
Overview
An abstract base class that returns service Objects such as Workspace or Players.
Properties
Methods
FindService
If a service with the specified name exists, it returns that service.
If the name is incorrect or the service hasn't been created yet, an error will occur.
Parameters
string
InClassName
The class name of the service to retrieve.
Return
Instance
The instance of the returned service.
Code Samples
local Workspace = game:FindService("Workspace")
local InvalidService = game:FindService("InvalidService")
GetService
If a service with the specified name exists, it returns that service.
If the provided name corresponds to a valid service, it returns the service if it already exists; if not, the service is automatically created and returned.
Parameters
string
InClassName
The class name of the service to retrieve.
Return
Instance
The instance of the returned service.
Code Samples
local Players = game:GetService("Players")
local Workspace = game:GetService("Workspace")
Events
See also
Object ReferenceLast updated