PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience

Removing Objects After a Time

Removing Objects After a Time

Jun 23 2018, 2:02 AM PST

Problem

You want to remove an object after a certain amount of time without interrupting a script’s execution.

Solution

Use the Debris/AddItem|AddItem() method of Debris.

game:GetService("Debris"):AddItem(game.Workspace.Part, 5)

Discussion

The Debris service is used to make objects automatically clean themselves up after a certain amount of time. You can add an object to the cleanup list by using Debris/AddItem|AddItem() and, as the second argument, specify the amount of time before the object is cleaned up (in seconds).

Tags:
  • remove
  • cleanup
  • time