Studio GuideWorld SDK Guide
Log In

Removing a specific user from Room

You can kick certain users out of the room at runtime.



  • Please create the server code index.ts Sandbox.

Function definition

kick(client: SandboxPlayer, reason?: string): Promise;It is a function to kick out the SandboxPlayer after receiving the SandboxPlayer with SessionID.

- If you are kicked out, a pop-up will appear informing you that you are kicked out, but the pop-up is the UI of the ZEPETO app and cannot be checked by the editor.


Please refer to the following guide. [ZEPETO.Multiplay(Server) API]

First, to get user information, define Schema Types and RoomState as follows:


Example of use

  • Use the data in UserInfos to get the session ID of the user who will be kicked out of the userId.
  • After importing the sandbox player with the session ID, call the kick function.
  • I can tell you who was kicked out through broadcast.
import { Sandbox, SandboxOptions, SandboxPlayer } from 'ZEPETO.Multiplay';
import { DataStorage, loadDataStorage } from 'ZEPETO.Multiplay.DataStorage';
import { UserInfo } from 'ZEPETO.Multiplay.Schema';

export default class extends Sandbox {

    onCreate(options: SandboxOptions) {
        this.onMessage("Kick", (client: SandboxPlayer, message: string) => {
            this.tryKick(client, message);

    onJoin(client: SandboxPlayer) {
        const user = new UserInfo();
        user.sessionId = client.sessionId;
        user.userId = client.userId;

        this.state.UserInfos.set(client.userId, user);

    async tryKick(client: SandboxPlayer, userId: string) {
        let player: SandboxPlayer;
        if (userId == null) {
            player = client;
        } else {
            const kickPlayerSessionId: string = this.state.UserInfos.get(userId).sessionId;
            player = this.loadPlayer(kickPlayerSessionId);

        console.log(`try kick : ${player.userId}`);
        await this.kick(player);

        this.broadcast("Log", `kick : ${player.userId}`);


By default, users who have been kicked out can enter the room again

  • To prevent this, use the DataStorage management function based on the UserId to store the room information that was kicked out by the user.
  • You can implement it by calling a kick when you try to enter the room.