Basically, is there any kinda code that is similar to game:GetService("Debris"):AddItem where it does a countdown but lets the script keep going?
I don't know why you would want to use any of these other methods, but I'll go over them anyways.
The first idea is using the Delay Function
. Here's the link to the wiki page about the delay function. An example would look like this,
script.Parent.Touched:connect(function(part) delay(1,function() part:Destroy() end) end)
Here's a short gif of this script in action.
Another is to use the Spawn Function
. This works similarly to the first method, but you can't pass the amount of time you want to wait into the function. This can easily be done with a wait, but it's worth noting.
script.Parent.Touched:connect(function(part) spawn(function() wait(1) part:Destroy() end) end)
I hope that gives you some insight, and that this answer was what you wanted.
Good Luck!
I have not used this function personally, but from what I've read on the wiki, delay
is what you are looking for. Use it like this:
delay(time, func)
Where time
is the time in seconds and func
is the function to run.