# 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 requested service instance. |
| ---------- | ------------------------------- |

#### Code Samples

```lua
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 requested service instance. |
| ---------- | ------------------------------- |

#### Code Samples

```lua
local Players = game:GetService("Players")
local Workspace = game:GetService("Workspace")
```

## Events

## See also

{% content-ref url="/pages/2QyvZhqC78UF4i0Nhcpr" %}
[Object Reference](/manual/script-manual/get-started/object-reference.md)
{% endcontent-ref %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.overdare.com/development/api-reference/classes/serviceprovider.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
