generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

a homeslice could use some help

Previous Thread :: Next Thread 
Quippers is not online. 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
NisosPhilemon is not online. NisosPhilemon
Joined: 09 Jul 2010
Total Posts: 587
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 is not online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image