Registers an event when a player is spawned (or re-spawned after death) and fully ready within the world.

Example

initialSpawnEvent.js

import { world } from "@minecraft/server";

world.afterEvents.playerSpawn.subscribe((eventData) => {
const { player, initialSpawn } = eventData;
if (!initialSpawn) return;

// This runs when the player joins the game for the first time!
});

Hierarchy

Constructors

Methods

Constructors

Methods

  • Parameters

    Returns ((arg) => void)

      • (arg): void
      • Parameters

        Returns void

        Remarks

        Subscribes to the event.

        This function can't be called in read-only mode.

    Remarks

    Subscribes to the event.

    This function can't be called in read-only mode.