Debris
Schedules part destruction after a delay.
- Service
game:GetService("Debris")- Inherits
- Instance
- Replication
- Never
Behavior
Debris schedules part destruction without yielding the calling thread.
Deadlines are checked periodically, so destruction may occur after the requested
delay.
Summary
The maximum number of items retained by Debris before earlier items are removed.
Queues a part for destruction after a minimum lifetime in seconds.
Returns this instance if it is an ExecutionGroup.
Properties
MaxItems
Debris.MaxItems: numberThe maximum number of items retained by Debris before earlier items are removed.
Methods
AddItem
Debris:AddItem(item: Instance, lifetime: number?): ()Queues a part for destruction after a minimum lifetime in seconds. Defaults to 10; negative lifetimes are treated as 0.
The current implementation accepts part userdata only. Other instance types are ignored. Repeated calls add queue entries and do not extend an existing deadline. When the queue reaches MaxItems, the oldest entries are removed from the queue without destroying their parts. A MaxItems value of 0 disables queueing.
GetExecutionGroup
Debris:GetExecutionGroup(): ExecutionGroup?Returns this instance if it is an ExecutionGroup. Otherwise returns the nearest ancestor ExecutionGroup, or nil when no group contains the instance.
Inherited members
- Properties
- ArchivableClassNameNameParent
- Methods
- AddComponent()AddTag()ClearAllChildren()ClearTags()Clone()Destroy()FindFirstAncestor()FindFirstAncestorOfClass()FindFirstAncestorWhichIsA()FindFirstChild()FindFirstChildOfClass()FindFirstChildWhichIsA()FindFirstDescendant()GetAttribute()GetAttributeChangedSignal()GetAttributes()GetChildren()GetComponent()GetComponentChangedSignal()GetComponents()GetDebugId()GetDescendants()GetFullName()GetPropertyChangedSignal()GetReferencing()GetTags()HasComponent()HasTag()IsA()IsAncestorOf()IsDescendantOf()RemoveComponent()RemoveTag()SetAttribute()WaitForChild()
- Events
- AncestryChangedAttributeChangedChangedChildAddedChildRemovedDescendantAddedDescendantRemovingDestroying
Example
local part = Instance.new("Part")
part.Anchored = true
part.Parent = workspace
game:GetService("Debris"):AddItem(part, 2)