[UPDATED]Debris Service 3

  • UpdateLog 10 / 20 / 2020 5:41pm GMT
    Added the option to add a ending tween to the part so you can make it fade at the end of its life time,
    Changed tick() to os.clock() basically just tick() but better

Currently Roblox’s debris service is very limited as the only function it has is add item, so when you want to add a new item you need to either need to do a loop or do it one by one which is very tideous and my custom debris service adds several new functions that the Roblox one doesn’t offer

– Offers support for instnaces, tables and RBXScriptConnections

Example code and the module are all on the github

Functions:

  • AddItem(Item, Lifetime, Info) Info is as follows
    {
    Duration = 3, – Needs to be an integer
    Tweeninfo = TweenInfo.new(1), – Needs to be a TweenInfo
    Goals = {
    [‘CFrame’] = CFrame.new(0,10,10),
    Transparency = 1,} – Needs to be a dictionary
    }

Adds the item to a queue and once the start time exceeds the life time it deletes / cleans up the item

  • AddItems(Items, Lifetimes, Info ) Template same as ‘AddItem’

Basically Additem but for multiple items and multiple different lifetimes

  • GetAllDebris()

Returns all the debris in the queue and all the info around them – Template is {Part, Lifetime, StartTime, Type, Info}

  • GetDebris(Item)

Returns the debris in the queue and the info around them – Template is the same as ‘GetAllDebris’

  • CancelItem(Item)

Removes the item from the queue if the item is in the queue

Thats it for all the functions
This is my first scripting forum post on here and I wish to do more for the community and offer more resources

Update 1 of ???

10 Likes

Nice module, I recommended disconnecting the heartbeat loop when there isn’t any objects left and using time() instead of tick()

The reason why I used tick is due to the fact that it the time of deletion needs to be exact otherwise it just rounds it to the nearest whole second which isn’t wanted in many usecases

time() doesn’t round, os.time() does

Tick() is VERY exact.

for x = 1,10 do

print(tick())

end

Try this it actually measures milliseconds between instructions, that’s how exact tick() is. Tick() does not round to the nearest whole number.


https://gyazo.com/87f6023688ca70662aef0e349084e60a

Maybe make an animation for an object when it is distorted. Like it sinks in the ground, it makes a lot of things look better then just vanishing. Make it an option of course.

1 Like

tick has floating point imprecision’s it isn’t as good as time(), time() doesn’t round to the nearest whole number either.

time also isn’t accurate at the start as it starts updating after everything has been loaded in however, tick is universal and scripts are one of the first things to load so it can cause inaccuracys if you want a part to be there at the start then disapear after a set amount of time, however I am going to change it to os.clock() because its what is making tick() redundant and kinda deprecated