Quick question I cant seem to find an answer too;
Regarding memory leaks, does Debris:AddItem() serve the same purpose as Destroy()?
They are the same, but Debris add item is usually used if you wanna have a delay for it being deleted. Debris:AddItem(“part”, 3) < would delete after 3 seconds
They are the same except the former creates a new thread so doesn’t yield the current thread.
Call Destroy() on anything you want to destroy instantaneously, Debris:AddItem has the same issues as spawn
, delay
and essentially wait
.
One issue is that if a client leaves right after calling Debris:AddItem() and the object wasn’t removed, the object won’t get destroyed and will take up memory (unless this information is now outdated and delay
keeps running after a client leaves).
Add item doesn’t error if the thing is nil while destroy does. Add item also gives you a delay to destroy an object.
:AddItem()
is basically just a delayed :Destroy()
.