> For the complete documentation index, see [llms.txt](https://ditoland-utplus.gitbook.io/ditoland/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ditoland-utplus.gitbook.io/ditoland/guide-for-developers/guide-for-roblox-developer.md).

# Guide For Roblox Developer

![](/files/-MZzVrikysr2pE28CHzR)

이 문서는 로블록스 개발자가 디토랜드에 쉽게 적응할 수 있도록 하기 위해 제작되었어요.&#x20;

## 에디터&#x20;

![](/files/-MZzXNHbgR1o7QbuF63W)

로블록스에서는 출력이 항상 표시되지만 디토랜드에서는 게임을 실행해야 표시돼요.&#x20;

![](/files/-MZzZG1SDQs9WESlc-0j)

디토랜드에서는 이동, 회전, 크기 편집 모드에서 선택 기능을 사용할 수 없어요.&#x20;

## 로블록스와 디토랜드의 차이점&#x20;

| 내용               | 로블록스                                                         | 디토랜드                             |
| ---------------- | ------------------------------------------------------------ | -------------------------------- |
| 오브젝트 편집 단축키      | <p>Ctrl + 1</p><p>Ctrl + 2</p><p>Ctrl + 3</p><p>Ctrl + 4</p> | <p>1</p><p>2</p><p>3</p><p>4</p> |
| 좌표계 (가로, 세로, 높이) | <p>X</p><p>Z</p><p>Y</p>                                     | <p>Y</p><p>X</p><p>Z</p>         |
| Part             | Part                                                         | StaticMesh                       |
| Model            | Model                                                        | <p>Group<br>Toy</p>              |
| Tool             | Tool                                                         | Item                             |
| Script           | Script                                                       | ServerScript                     |
| LocalScript      | LocalScript                                                  | ClientScript                     |
| Gui              | Gui                                                          | UI                               |

### 탐색기 구성 요소 비교&#x20;

![](/files/-MZzbpfrKmZm1hHz5_oq)

### 스크립트 실행 가능 여부&#x20;

#### 스크립트(서버 스크립트)의 경우&#x20;

| 위치 ( 로블록스 / 디토랜드 )                  | 로블록스 | 디토랜드 |
| ----------------------------------- | ---- | ---- |
| Workspace                           | 가능   | 가능   |
| ServerScriptService / ScriptServer  | 가능   | 가능   |
| StarterPlayerScripts / ScriptClient | 가능   | 불가   |
| StarterGui / HUD                    | 가능   | 불가   |
| ReplicatedStorage / Toybox          | 불가   | 불가   |

#### 로컬 스크립트(클라이언트 스크립트)의 경우&#x20;

| 위치 ( 로블록스 / 디토랜드 )                  | 로블록스                                                | 디토랜드 |
| ----------------------------------- | --------------------------------------------------- | ---- |
| Workspace                           | 불가                                                  | 가능   |
| ServerScriptService / ScriptServer  | <p>불가 </p><p>(단, 특정 플레이어의 <br> 캐릭터 모델 안에서는 가능) </p> | 불가   |
| StarterPlayerScripts / ScriptClient | 가능                                                  | 가능   |
| StarterGui / HUD                    | 가능                                                  | 가능   |
| ReplicatedStorage / Toybox          | 불가                                                  | 불가   |

### 스크립트를 읽는 순서&#x20;

#### 스크립트(서버 스크립트)의 경우&#x20;

로블록스의 스크립트는 무작위 순서로 읽어요.&#x20;

새로 생성된 스크립트는 실행 가능한 위치에 있다면 생성되는 시점에서 읽어요.&#x20;

디토랜드에서 서버 스크립트는 **ScriptServer**에 있는 스크립트를 제일 먼저 읽고, Workspace에 있는 스크립트는 순서대로 읽습니다.&#x20;

동적으로 생성된 오브젝트의 스크립트들은 생성되는 시점에서 읽어요.

#### 로컬 스크립트(클라이언트 스크립트)의 경우&#x20;

로블록스의 로컬 스크립트는 ReplicatedFirst에 있는 스크립트를 제일 먼저 읽고, 나머지는 무작위 순서로 읽어요.&#x20;

새로 생성된 스크립트는 실행 가능한 위치에 있다면 생성되는 시점에서 읽어요.&#x20;

디토랜드에서 클라이언트 스크립트는 **ScriptClient**에 있는 스크립트를 제일 먼저 읽고, Workspace에 있는 스크립트는 순서대로 읽습니다.&#x20;

동적으로 생성된 오브젝트의 스크립트들은 생성되는 시점에서 읽어요.

### 전역 객체의 호출 방식&#x20;

| 로블록스                                                                         | 디토랜드         |
| ---------------------------------------------------------------------------- | ------------ |
| workspace                                                                    | Workspace    |
| game                                                                         | Game         |
| <p>game.StarterGui</p><p>game:GetService("StarterGui")</p>                   | HUD          |
| <p>game.ServerScriptService</p><p>game:GetService(“ServerScriptService”)</p> | ScriptServer |
| -                                                                            | ScriptClient |
| <p>game.ReplicatedStorage</p><p>game:GetService(“ReplicatedStorage”)</p>     | Toybox       |
| script                                                                       | Script       |

로블록스의 전역 객체 변수(Roblox Globals)는 workspace, game와 같이 첫 글자가 소문자로 시작하지만, 디토랜드는 대문자로 시작해요.&#x20;

디토랜드는 HUD, ScriptServer 등의 객체들까지 전역 변수로 호출할 수 있어요.&#x20;

### 에디터 모드에서 변수 편집&#x20;

로블록스는 IntValue, BoolValue 등 값을 저장하기 위한 객체가 따로 있지만, 디토랜드에서는 **프로퍼티창**의 **Script Parameters 항목**에서 추가할 수 있습니다.&#x20;

![](/files/-MX9zDmXxNc12px-yFJg)

Script Parameters에서 추가한 변수는 아래의 방법으로 접근할 수 있습니다. &#x20;

```lua
--추가한 변수가 Script 자신에게 있으면 
local MoveSpeed = Script.MoveSpeed
local JumpSpeed = Script.JumpSpeed

--추가한 변수가 오브젝트나 다른 스크립트에 있으면 
local Toy = Script.Parent
local Damage = Toy.Damage
local BulletSpeed = Toy.Bullet.BulletServerScript.BulletSpeed
```

### 서버<->클라이언트 스크립트간 함수 호출&#x20;

로블록스는 오직 RemoteEvent, BindableEvent로만 이벤트를 보낼 수 있지만, 디토랜드는 어떤 개체에서든지 이벤트를 보낼 수 있습니다.&#x20;

[이벤트 샘플](/ditoland/sample/event.md#undefined-1)의 BoradcastEvent, SendEventToServer, SendEventToClient를 참고하세요.&#x20;

## 로블록스의 기능를 디토랜드에서 사용하기&#x20;

### 기본 이벤트 함수

| 로블록스                        | 디토랜드                  |
| --------------------------- | --------------------- |
| game.Players.PlayerAdded    | Game.OnEnterPlayer    |
| game.Players.PlayerRemoving | Game.OnLeavePlayer    |
| player.CharacterAdded       | Game.OnSpawnCharacter |
| humanoid.Died               | Game.OnDeathCharacter |

### 충돌 체크

{% tabs %}
{% tab title="Collision" %}

```lua
--스태틱메쉬나 콜라이더의 Collision 프로퍼티가 true면 동작합니다.
local Cube = Workspace.Cube

--충돌영역에 대상이 있을때 호출됩니다. 
--충돌영역 안에서 대상이 움직일때도 호출됩니다. 
local function Collision(self, target)
    if target == nil or not target:IsCharacter() then
        return
    end
    
    print("Target : " .. target.Name)
end
Cube.Collision.OnCollisionEvent:Connect(Collision)
```

{% endtab %}

{% tab title="Trigger" %}

```lua
--콜라이더의 Collision 프로퍼티가 false면 동작합니다. 
local BoxCollider = Workspace.BoxCollider

--충돌영역에 대상이 닿았을때 호출됩니다. 
local function EnterTrigger(self, target)
    if target == nil or not target:IsCharacter() then
        return
    end
    
    print("Enter Target : " .. target.Name)
end
Cube.Collision.OnBeginOverlapEvent:Connect(EnterTrigger)

--충돌영역 안에 대상이 있을때 계속 호출됩니다. 
local function UpdateTrigger(self, target)
    if target == nil or not target:IsCharacter() then
        return
    end
    
    print("Update Target : " .. target.Name)
end
Cube.Collision.OnOverlapUpdateEvent:Connect(UpdateTrigger)

--충돌영역에서 대상이 나갔을때 호출됩니다. 
local function ExitTrigger(self, target)
    if target == nil or not target:IsCharacter() then
        return
    end
    
    print("Exit Target : " .. target.Name)
end
Cube.Collision.OnEndOverlapEvent:Connect(ExitTrigger)
```

{% endtab %}
{% endtabs %}

### Clone과 Destroy&#x20;

{% tabs %}
{% tab title="Server Script" %}

```lua
local cube = Workspace.Cube
local createPos = Vector.new(1, 3, 2)

--Clone처럼 동작합니다. 
local temp = Game:CreateSyncObject(cube, createPos, "Cube", Workspace)
wait(2)

--Destroy처럼 동작합니다.
Game:DeleteObject(temp)
```

{% endtab %}
{% endtabs %}

### **GetChildren**() &#x20;

{% tabs %}
{% tab title="Server Script" %}

```lua
local ObjectList = Workspace:GetChildList() 

--#ObjectList는 transform.childCount처럼 동작합니다. 
for i = 1, #ObjectList, 1 do
    print(ObjectList[i].Name)
end
```

{% endtab %}
{% endtabs %}

### 더 많은 기능을 보려면&#x20;

[샘플 맵](/ditoland/sample.md)이나  [API Reference](/ditoland/api-reference.md)를 참고하세요.&#x20;

## 컨텐츠 제작 강좌  <a href="#undefined-3" id="undefined-3"></a>

{% content-ref url="/pages/-MVtaEEMjggOg6xaCW4B" %}
[Tutorial](/ditoland/tutorial.md)
{% endcontent-ref %}
