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.
Methods
Section titled “Methods”addItem
Section titled “addItem”addItem(instance: Instance, seconds: number): voidDestroys instance after seconds of game time (0: on the next step).
Examples
Section titled “Examples”Throwaway projectiles
Section titled “Throwaway projectiles”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