I know Debris only adds items. I want to be able to remove an item from a scheduled deletion.
Debris:AddItem(item, 60) will delete an item after 60 seconds.
What I want is to delete an item after 60 seconds of lack of use, but to stop the timer if X happens.
db = false
coroutine.wrap(function ()
local startTime = tick ()
repeat
task.wait(1)
until db or (tick()-startTime) > 60
if not db then
item:Destroy()
end
end)()
The problem is I can’t depend on a single variable (there will be potentially dozens of items scheduled for deletion).
item:SetAttribute("Debris", true)
coroutine.wrap(function ()
local startTime = tick ()
repeat
task.wait(1)
until not item:GetAttribute("Debris") or (tick()-startTime) > 60
if item:GetAttribute("Debris") then
item:Destroy()
end
end)()
This works, but is hideous! Does anyone know a better way?