Registers an event when a player is spawned (or re-spawned after death) and fully ready within the world.
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!}); Copy
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!});
export class PlayerSpawnAfterEventSignal { private constructor(); subscribe(callback: (arg0: PlayerSpawnAfterEvent) => void): (arg0: PlayerSpawnAfterEvent) => void; unsubscribe(callback: (arg0: PlayerSpawnAfterEvent) => void): void;} Copy
export class PlayerSpawnAfterEventSignal { private constructor(); subscribe(callback: (arg0: PlayerSpawnAfterEvent) => void): (arg0: PlayerSpawnAfterEvent) => void; unsubscribe(callback: (arg0: PlayerSpawnAfterEvent) => void): void;}
Private
Registers a new event receiver for this particular type of event.
no-restricted-execution - This function can't be called in restricted-execution mode.
early-execution-allowed - This function can be called in early-execution mode.
De-registers an event receiver for the player spawn event.
Registers an event when a player is spawned (or re-spawned after death) and fully ready within the world.
Example: initialSpawnEvent.js
Source