Skip to content

Debris

Removes objects later, even if the script that asked stops first.

  • Get it: import { Debris } from '@rally/sdk'

task.delay(4, () => ball.destroy()) belongs to the script that called it: if that script stops, or restarts because its code changed in a Build live session, the timer is cancelled and the ball stays. Debris.addItem(ball, 4) hands the removal to the game, so it happens on time whatever happens to the script. Time is game time, like task.

addItem(instance: Instance, seconds: number): void

Destroys instance after seconds of game time (0: on the next step).

import { Debris, Part, Vector3, workspace } from '@rally/sdk';
const ball = new Part();
ball.shape = 'sphere';
ball.size = new Vector3(1, 1, 1);
ball.position = new Vector3(0, 10, 0);
ball.parent = workspace;
Debris.addItem(ball, 4); // gone in 4 seconds, even if this script restarts