Are there any property that replicates game.Debris:AddItem() but for properties?

Hello i’ve been using the game.Debris:AddItem() thingy a lot recently, and it really helped organizing my code without having to use task.wait() as much. but i’m wondering is there anything similar to this that works with properties? like I would usually just do this:

local particle = script.Parent.ParticleEmitter

particle.Enabled = true
task.wait(5)
particle.Enabled = false

and it would make the line of codes under it wait as well, Debris:AddItem() doesnt need to use wait() because it sets the lifetime of the part but are there anything similar to this for properties?

Use task.delay. It runs the wait on a new “thread” (in quotations because it’s not an actual thread), which prevents any code outside of the function from being yielded too.

Code:

local particle = script.Parent.ParticleEmitter

particle.Enabled = true

task.delay(5, function()
	particle.Enabled = false
end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.