# ScriptConnection

## Overview

ScriptConnection is a connection object that connects a function written in Lua script to an event.

This object is created when Connect is called and plays an important role in event management by providing a way to stop event handling using the Disconnect function.

## Constructors

## Properties

### Connected

`boolean`

A property representing event connection status.

Returns false when the Disconnect method is called.

#### Code Samples

```lua
local Players = game:GetService("Players")
local Connection = nil

local function EnterPlayer(player)
    print("EnterPlayer : ", player.Name)
end
Connection = Players.PlayerAdded:Connect(EnterPlayer)

if Connection.Connected then
    print("The connection is active.")
else
    print("The connection has been disconnected.")
end
```

## Methods

### Disconnect

Disconnects event and no longer receives the signal.

#### Parameters

#### Return

| `void` |   |
| ------ | - |

#### Code Samples

```lua
Connection:Disconnect()
```

## Events

## See also


---

# 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/datatype/scriptconnection.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.
