Quippers
|
  |
| Joined: 12 Jul 2013 |
| Total Posts: 2787 |
|
|
| 30 Apr 2016 11:21 PM |
while true do Instance.new("Part" , workspace).BrickColor = BrickColor.Random() wait(1) --I want to destroy a part after a certain amount of seconds to reduce lag end
|
|
|
| Report Abuse |
|
|
|
| 30 Apr 2016 11:22 PM |
while true do local Part = Instance.new("Part" , workspace) Part.BrickColor = BrickColor.Random()
game.Debris:AddItem(Part, 1) -- Add your time on the second arg end
RAP 25,707 ; Typical scripting forum browser and helper. |
|
|
| Report Abuse |
|
|
Jammer622
|
  |
| Joined: 19 Nov 2008 |
| Total Posts: 1739 |
|
|
| 30 Apr 2016 11:24 PM |
Make a local variable to reference the part, then use :Destroy() to remove it.
while true do local p = Instance.new("Part", Workspace) p.BrickColor = BrickColor.random() wait(1) p:Destroy() end |
|
|
| Report Abuse |
|
|
Jammer622
|
  |
| Joined: 19 Nov 2008 |
| Total Posts: 1739 |
|
|
| 30 Apr 2016 11:26 PM |
@nisos oh my. don't forget to add the wait().
But yeah, if you want more than one part spawned at a time, like say 3, use the Debris service. In a case like that, you can place your wait() in the same line as your while-do loop.
while wait(1) do local p = Instance.new("Part", Workspace) p.BrickColor = BrickColor.random() game:GetService("Debris"):AddItem(p, 3) end |
|
|
| Report Abuse |
|
|