Glorpia Docs
Services

DebrisService

Schedules Instances to be destroyed after a delay without blocking the current script.

Access

Luau
local DebrisService = game:GetService("DebrisService")
game:GetService("Debris") and game.Debris are compatibility aliases for the same service.

Members

NameTypeDescription
NamestringDebrisService.
ClassNamestringDebrisService.
AddItem(instance, lifetime)methodSchedules the Instance to be destroyed after lifetime seconds. If lifetime is omitted, it defaults to 10 seconds.

AddItem()

DebrisService:AddItem(instance, lifetime?)

AddItem() returns immediately. Destruction is scheduled through the runtime task scheduler, so the current script does not wait for the lifetime to expire.

A negative lifetime is treated as 0. The lifetime must be a finite number. If the Instance has already been destroyed when the timer expires, the cleanup attempt is ignored.

Example

Luau
local DebrisService = game:GetService("DebrisService")

local part = Instance.new("Part")
part.Name = "TemporaryPart"
part.Parent = workspace

DebrisService:AddItem(part, 5)

Related