# Event Execution Order

### 기본 이벤트

플레이어의 입장과 퇴장 / 캐릭터의 스폰과 죽음에 관한 이벤트 호출 순서 및 상세설명이에요.

<table data-header-hidden><thead><tr><th width="247"></th><th></th></tr></thead><tbody><tr><td><strong>OnTeleportFinishEvent</strong></td><td>플레이어가 해당 랜드로 이동을 완료했을 때 호출되는 이벤트예요.</td></tr><tr><td><strong>OnTeleportFailedEvent</strong></td><td>플레이어가 해당 랜드로 이동을 실패했을 때 호출되는 이벤트예요.</td></tr><tr><td><strong>OnEnterPlayer</strong></td><td>플레이어가 입장할 때 호출되는 이벤트예요.</td></tr><tr><td><strong>OnSpawnCharacter</strong></td><td>캐릭터가 스폰 될 때 호출되는 이벤트예요.</td></tr><tr><td><strong>OnDeathCharacter</strong></td><td>캐릭터가 죽을 때 호출되는 이벤트예요.</td></tr><tr><td><strong>OnLeavePlayer</strong></td><td>플레이어가 랜드에서 나갈 때 호출되는 이벤트예요.</td></tr></tbody></table>

<figure><img src="/files/EsdicSBejvBsGounOEHh" alt=""><figcaption><p>이미지를 클릭하면 확대해서 볼 수 있어요.</p></figcaption></figure>

#### OnTeleportFinishEvent

: 플레이어가 해당 랜드로 이동을 완료했을 때 호출되는 이벤트예요.

⇒ 🚫 랜드 이동을 하지 않았을 경우, 해당 이벤트는 호출되지 않아요.

#### OnTeleportFailedEvent

: 플레이어가 해당 랜드로 이동을 실패했을 때 호출되는 이벤트예요.

⇒ 🚫 랜드 이동을 하지 않았을 경우, 해당 이벤트는 호출되지 않아요.

#### OnEnterPlayer

: 플레이어가 입장할 때 호출되는 이벤트예요.

⇒ 📢 해당 이벤트는 플레이가 입장했을 때 한번만 호출돼요.

⇒ 💡ClientScript에서 해당 이벤트를 호출할 경우, IsMyPlayer 함수를 이용해 입장한 플레이어가 \
로컬 플레이어인지 확인할 수 있어요.

⇒ 🚫 캐릭터 객체에 대한 접근이 필요한 경우 OnSpawnCharacter에서 접근하는 것을 권장해요.

#### OnSpawnCharacter

: 캐릭터가 스폰 될 때 호출되는 이벤트예요.

⇒ 📢 해당 이벤트는 캐릭터가 스폰될 때 매번 호출돼요.

⇒ 💡ClientScript에서 해당 이벤트를 호출할 경우, IsMyCharacter 함수를 이용해 스폰한 캐릭터가 \
로컬 캐릭터인지 확인할 수 있어요.

#### OnDeathCharacter

: 캐릭터가 죽을 때 호출되는 이벤트예요.

⇒ 📢 해당 이벤트는 캐릭터가 죽을 때 매번 호출돼요.

⇒ 💡ClientScript에서 해당 이벤트를 호출할 경우, IsMyCharacter 함수를 이용해 죽은 캐릭터가 \
로컬 캐릭터인지 확인할 수 있어요.

#### OnLeavePlayer

: 플레이어가 랜드에서 나갈 때 호출되는 이벤트예요.

⇒ 📢 해당 이벤트는 플레이가 나갔을 때 한번만 호출돼요.

⇒ 💡ClientScript에서 해당 이벤트를 호출할 경우, IsMyPlayer 함수를 이용해 나간 플레이어가 \
로컬 플레이어인지 확인할 수 있어요.

⇒ 🚫 ClientScript에서 해당 이벤트를 호출해 캐릭터에 접근할 때는 로컬 캐릭터만 가능해요.

⇒ 🚫 해당 이벤트에 연결된 함수에서 GetAllPlayer / GetPlayerCount 함수를 사용해 남아 있는 \
플레이어의 값을 가져올 경우, 방금 나간 플레이어의 값을 제외해줘야 해요.

```lua
--GetAllPlayer

local function LeavePlayer(player)
    local allPlayer = Game:GetAllPlayer()

    for i = 1, #allPlayer do
        if allPlayer[i] == player then
            table.remove(allPlayer, i)
            break
    	end
    end

    print("AllPlayerCount :", #allPlayer)
end
Game.OnLeavePlayer:Connect(LeavePlayer)
```

```lua
--GetPlayerCount

local function LeavePlayer(player)
    local allPlayerCount = Game:GetPlayerCount() - 1

    print("AllPlayerCount :", allPlayerCount)
end
Game.OnLeavePlayer:Connect(LeavePlayer)
```

***

***

### 오브젝트 이벤트

오브젝트와 관련된 이벤트의 호출 순서 및 상세설명이에요.

<table data-header-hidden><thead><tr><th width="204"></th><th></th></tr></thead><tbody><tr><td><strong>OnUpdateEvent</strong></td><td><p>오브젝트가 Enable 상태일 때 매프레임 호출되는 이벤트예요.</p><p>*오브젝트가 Disable 상태일 때는 호출되지 않아요.</p></td></tr><tr><td><strong>OnEnableEvent</strong></td><td>오브젝트가 Enable 상태로 변경됐을 때 호출되는 이벤트예요.</td></tr><tr><td><strong>OnDisableEvent</strong></td><td>오브젝트가 Disable 상태로 변경됐을 때 호출되는 이벤트예요.</td></tr><tr><td><strong>OnDestroyEvent</strong></td><td>오브젝트가 삭제될 때 호출되는 이벤트예요.</td></tr></tbody></table>

<figure><img src="/files/pCWBAbqnwgGSyPqT1SGn" alt=""><figcaption></figcaption></figure>

#### OnUpdateEvent

: 오브젝트가 Enable 상태일 때 매프레임 호출되는 이벤트예요.

⇒ 🚫 오브젝트가 Disable 상태일 때는 호출되지 않아요. ( 오브젝트.Enable = false )

#### OnEnableEvent

: 오브젝트가 Enable 상태로 변경됐을 때 호출되는 이벤트예요.

⇒ 📢 오브젝트의 Enable을 변경해 주었을 때 호출돼요. ( 오브젝트.Enable = true )

#### OnDisableEvent

: 오브젝트가 Disable 상태로 변경됐을 때 호출되는 이벤트예요.

⇒ 📢 오브젝트의 Enable을 변경해 주었을 때 호출돼요. ( 오브젝트.Enable = false )

#### OnDestroyEvent

: 오브젝트가 삭제될 때 호출되는 이벤트예요.

⇒ 📢 해당 이벤트는 오브젝트가 삭제되었을 때 한번만 호출돼요.

***

***

***

### UI ( ScreenUI / SurfaceUI ) 이벤트

UI ( ScreenUI / SurfaceUI ) 와 관련된 이벤트의 호출 순서 및 상세 설명이에요.

<table data-header-hidden><thead><tr><th width="204"></th><th></th></tr></thead><tbody><tr><td><strong>OnUpdateEvent</strong></td><td><p>UI의 상태가 Enable일 때, 매 프레임마다 호출되는 이벤트에요.</p><p>*UI의 상태가 Disable이면 호출되지 않아요.</p></td></tr><tr><td><strong>OnVisibleEvent</strong></td><td>UI가 보여질 때 호출되는 이벤트에요.</td></tr><tr><td><strong>OnInVisibleEvent</strong></td><td>UI가 안 보여질 때 호출되는 이벤트에요.</td></tr></tbody></table>

<figure><img src="/files/frEQ7t2VUc5ElS3n2kAz" alt=""><figcaption></figcaption></figure>

#### OnUpdateEvent

: UI ( ScreenUI / SurfaceUI ) 의 상태가 Enable일 때, 매 프레임마다 호출되는 이벤트에요.

⇒ 🚫 UI의 상태가 Disable이면 호출되지 않아요.

#### OnVisibleEvent

: UI ( ScreenUI / SurfaceUI ) 가 보여질 때 호출되는 이벤트에요.

⇒ 📢 UI를 보이도록 변경해 주었을 때 호출돼요.

&#x20;   ( UI.Visible = true / UI.Enable = true )

#### OnInVisibleEvent

: UI ( ScreenUI / SurfaceUI ) 가 안 보여질 때 호출되는 이벤트에요.

⇒ 📢 UI를 보이지 않도록 변경해 주었을 때 호출돼요.

&#x20;   ( UI.Visible = true / UI.Enable = true )

***

### Enable 속성과 이벤트/함수 동작

Enable 속성은 일부 이벤트/함수 동작에 영향을 줘요.&#x20;

영향을 받는 이벤트/함수는 Enable 상태일 때 동작, Disable 상태일 때는 동작하지 않아요.

🚫 Disable 상태이더라도, Lua 코드는 여전히 동작해요. ( 스크립트 로직, wait, for, while 등 )

#### Enable 속성에 영향을 받는 이벤트/함수

( Enable 상태 → 동작 / Disable 상태 → 동작 X )

* OnUpdateEvent
* OnCollisionEvent
* OnBeginOverlapEvent
* OnEndOverlapEvent
* OnOverlapUpdateEvent
* Track.PlayTransformTrack

  ⇒ Track.PlayTransformTrack 함수의 경우, \
  Disable 상태가 되면 월드 내 움직임이 멈추고, Enable 상태가 되면 다시 움직여요.<br>

  🚫 Disable 상태이더라도, Track의 재생이 완전히 끝나거나 정지 상태가 아니면 \
  월드 내 움직임은 멈추지만 Track은 여전히 재생 중이에요.\ <br>


---

# 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://ditoland-utplus.gitbook.io/ditoland/manual/event-execution-order.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.
