the title explains itself
how do I make a script that despawns a part after a little while?
the title explains itself
how do I make a script that despawns a part after a little while?
just have this script inside the part:
wait(100) --This is 100 seconds for example.
script.Parent:Destroy() --Destroys the part.
Do you want the time to be a random time between times?
Like, a random number in between 30 and 40 seconds.
yes, something like that 30charrrrrssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss
Okay. Put this script inside of the part.
local number = math.random(30,40) -- Change "30,40" to numbers you want the random number to be selected within.
wait(number)
script.Parent:Destory()
Sorry if my comment above is messed up. I am currently on low Reception lol
You should use Debris:AddItem()
for this, not wait
. The article should explain why.
game:GetService("Debris"):AddItem(script.Parent, math.random(30, 40))
Wow, you just introduced me to both the Debris service and the task.wait() function (which was in the article), dang those are both so useful! If only I learned that a few years ago.