Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

What is the good of AddItem(), like in scripts?

Like what kind of items what do they mean? Like what items add or added? Also when should I use them in a script?

3 comments

0

Do you mean for Debris?

0

No, what the good of it.

0

You need to explain your question better, Debris Service is the only thing that has the method AddItem. Unless you have a script that has its own function AddItem.

1 answer

✓ Accepted answer

I think you're talking about the Debris service. This is used to remove an Instance after a set period of time.

Example:

local Debris = game:GetService("Debris") -- Define the Debris service. This isn't really necessary but I'm told there's less latency when using GetService().
local Part = Instance.new("Part", game.Workspace) -- Create the part

Debris:AddItem(Part, 10) -- It will be removed in 10 seconds.

This is pretty much the same as:

local Part = Instance.new("Part", game.Workspace) -- Create the part

wait(10) -- Yield the thread for 10 seconds
Part:Destroy() -- Remove the part.

With Debris, you don't need to yield your script, you can simply tell it to remove your Instance in 10 seconds and move on!

This discussion is preserved as it was. New answers, comments, and votes are closed.