---
title: プライベートルームの実行時設定
slug: world-sdk-guide-ja/Xur1OhiLqmbF-Dz6q_w4t
docTags: 
createdAt: 2024-09-02T08:34:13.135Z
---

ランタイムでマルチプレイヤールームの属性を変更できます。

:::hint{type="danger"}
- サーバーコード index.ts サンドボックスを作成してください。
:::



## 関数定義

|                                           |                                                  |
| ----------------------------------------- | ------------------------------------------------ |
| SetPrivate(isPrivate : boolean) : Promise | - True : プライベートルームに設定<br />- False : パブリックルームに設定 |

:::hint{type="info"}
**📘&#x20;**&#x6B21;のガイドを参照してください。 \[[ZEPETO.Multiplay(Server) API](https://developer.zepeto.me/docs/multiplay-server/classes/ZEPETO_Multiplay.Sandbox#setprivate)]
:::

## 使用例

```typescript
import { Sandbox, SandboxOptions, SandboxPlayer } from 'ZEPETO.Multiplay';

export default class extends Sandbox {
    
    onCreate(options: SandboxOptions) {
        this.onMessage("SetPrivate", (client: SandboxPlayer, value: boolean) => {
            console.log(`プライベート設定を試みています : ${value}`);
            this.SetPrivateRoom(client, value);
        });
    }
    
    async SetPrivateRoom(client: SandboxPlayer, value: boolean) {
        await this.setPrivate(value);
        client.send("Log", `ルームがプライベートに設定されました : ${this.private}`);
    }
}
```

:::hint{type="success"}
**👍 ロック機能とプライベート機能の違い**

ロックされたマルチプレイヤールームはZEPETOのルームリストに表示されず、招待なしでは入室できません。

- プライベートマルチプレイヤールームはZEPETOのルームリストに表示されませんが、招待は受け付けられます。
:::

