Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to create a part every x seconds but have them destroyed after y seconds of existing?

Asked by 1 year ago
Edited 1 year ago

Let x and y be arbitrary positive integers. In this while loop, how do I make every new part get destroyed after it has existed for y seconds?

while true do
p = Instance.new("Part",game.Workspace)
wait(x)
end

1 answer

Log in to vote
0
Answered by 1 year ago

Easy here: Destroy() command lets thing disappear from game. Here is it:

function creating()
    p = Instance.new("Part",game.Workspace)
    wait(y)
    p:Destroy()
end
while true do
    creating()
    wait(x)
end

0
A better solution would be to use the debris service Feroxidus 83 — 1y
Ad

Answer this question