Skip to content

objects.destroy

Removes one of your objects for every player. Its ID is not used again until the server restarts.

objects.destroy(id: number): Promise<ActionResult>
Name Type Description
id number The ID returned by objects.create.

A promise of an ActionResult. applied means the object was removed. Invalid IDs return invalid-object-id; an unknown or already removed ID returns object-not-found.

gamemodes/my-mode.ts
import { objects, server } from "nativemp";
const objectId = 0; // the ID objects.create returned
const result = await objects.destroy(objectId);
if (result.status === "applied") server.log("The object was removed");

scriptObjectDestroyed follows; by then the object is no longer in objects.listAll.