# Speaker Object

### Methods

#### getPlayer

```lua
local speaker = API.speaker.cache("Player1")
print(speaker:GetPlayer())
```

This method will return a [player object](https://developer.roblox.com/en-us/api-reference/class/Player) if the speaker is assigned to one.

#### addToChannel

```lua
local speaker = API.speaker.cache("Player1")
speaker:addToChannel("all")
```

This method will add the specified speaker to the specified [channel object.](https://jumpathy.gitbook.io/betterchat-documentation/plugin-api/server/channel-object)

| Type   | Name         |
| ------ | ------------ |
| string | channel name |

#### isinChannel

```lua
local speaker = API.speaker.cache("Player1")
speaker:addToChannel("all")
local isInChannel = speaker:isInChannel("all")
print(isInChannel)
```

This method will return a boolean that tells you if the speaker is in the specified [channel object.](https://jumpathy.gitbook.io/betterchat-documentation/plugin-api/server/channel-object)

| Type   | Name         |
| ------ | ------------ |
| string | channel name |

#### destroy

```lua
local speaker = API.speaker.cache("Player1")
speaker:Destroy()
```

This method will destroy all the connections of the specified speaker and remove their functions. This essentially is the same as destroying a part, it renders it useless.

| Type   | Name         |
| ------ | ------------ |
| string | speaker name |
