# BindableEvent

## 개요

BindableEvent를 이용하여, 서버와 서버 또는 클라이언트와 클라이언트와 같이 같은 환경내 통신 처리를 구현할 수 있습니다.

## BindableEvent 오브젝트

**BindableEvent**는 같은 환경간의 이벤트를 처리하기 위해 제공되는 오브젝트로 **단방향 통신**을 지원합니다.\
\
![](/files/c7VkvG5Fm6rrQb3rSgMK)

**💡 Tip. BindableEvent**의 용도가 서버에서 서버로의 통신인지(Server to Server), 클라이언트에서 클라이언트로의 통신인지를(Client to Client) 명확히 구분하기 위해, **이름에 접두어**로 **S2S\_** 또는 **C2C\_**&#xB97C; 사용하는 것을 권장합니다. 이는 이벤트의 역할을 직관적으로 이해할 수 있게 하여 코드의 가독성과 유지보수성을 높입니다.\
![](/files/eNqLfOpNqFHYVqtP6aeY)

## BindableEvent를 이용한 통신 구현

BindableEvent로 이벤트 발송시 **인자(Arguments)**&#xB97C; 함께 전송할 수 있습니다. 인자는 Fire 메서드 호출 시 전달되며, 수신 측에서 해당 데이터를 콜백 함수로 받을 수 있습니다.

### Server ➡ Server

**Script1에서**

```lua
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local S2S_SomeEvent = ReplicatedStorage:WaitForChild("S2S_SomeEvent")

local function TestFire()
    local SomeText = "BindableEvents"
    S2S_SomeEvent:Fire(SomeText) -- Passing arguments
end
```

**Script2에서**

<pre class="language-lua"><code class="lang-lua"><strong>local ReplicatedStorage = game:GetService("ReplicatedStorage")
</strong>local S2S_SomeEvent = ReplicatedStorage:WaitForChild("S2S_SomeEvent")

local function OnSomeEvent(text)
    print("[SomeEvent]", "Parameter : ", text)
end
S2S_SomeEvent.Event:Connect(OnSomeEvent)
</code></pre>

### Client ➡ Client

**LocalScript1에서**

```lua
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local C2C_SomeEvent = ReplicatedStorage:WaitForChild("C2C_SomeEvent")

local function TestFire()
    local SomeText = "BindableEvents"
    C2C_SomeEvent:Fire(SomeText) -- Passing arguments
end
```

**LocalScript2에서**

```lua
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local C2C_SomeEvent = ReplicatedStorage:WaitForChild("C2C_SomeEvent")

local function OnSomeEvent(text)
    print("[SomeEvent]", "Parameter : ", text)
end
C2C_SomeEvent.Event:Connect(OnSomeEvent)
```


---

# 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/korean/manual/script-manual/events-and-communication/bindableevent.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.
