Hello! I am currently working on a free build type of game and I wanted the blocks that the players built to get added to debris for 60 seconds, but if they joined back, their blocks would be removed from the debris. Is there a way to do this? And if not, should I use Destroy for this?
2 Likes
you might as well do something else, because debris only has two functions
Nope, there are simply no other function with the Debris service allowing for this to happen, there is only :AddItem and SetLegacyMaxitems from the Debris | Roblox Creator Documentation documentation as @D0RYU said.
You can instead use a custom task scheduling function with a cancel function like this post.
local function Destroyed(x)
if x.Parent then
return false
end
local _, result = pcall(function()
x.Parent = x
end)
return result:match("locked") and true or false
end
local function customDebris(instance, lifetime)
local continueDebris = true
coroutine.wrap(function()
task.wait(lifetime)
local isDestroyedAlready = Destroyed(instance)
if continueDebris and instance and not isDestroyedAlready then
instance:Destroy()
end
end)()
return function()
continueDebris = false
end
end
local cancelDebrisForPart = customDebris(Instance.new("Part"),5)
wait(1)
cancelDebrisForPart()
3 Likes
oh okay, thanks for the fast answer