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 » Game Design
Home Search
 

Help with this clean up script!

Previous Thread :: Next Thread 
FallenTacoz is not online. FallenTacoz
Joined: 05 Aug 2013
Total Posts: 328
14 Mar 2015 05:58 PM
Hi, I am trying to seek help for this little clean up code I made. It's supposed to remove any part in the workspace that is unlocked. This is what it is:

local part = game.Workspace:GetChildren()
if part.Locked then
print("Part Removed")
part:remove() else
return
end

It isn't working.. Can you help me?
Report Abuse
IIIIIIlII is not online. IIIIIIlII
Joined: 06 Jan 2011
Total Posts: 710
14 Mar 2015 06:02 PM
Use a for loop to loop through all the parts in a model

local model = game.Workspace:WaitForChild("ModelName")

for i = 1,#model do
if model[i]:IsA("BasePart") and model[i].Locked = false then
model[i]:Destroy() -- :remove() is deprecated
end
end
Report Abuse
championbuilder is not online. championbuilder
Joined: 20 Jan 2009
Total Posts: 13544
14 Mar 2015 06:07 PM
for _,v in pairs(game.Workspace:GetChildren()) do
if v:IsA("Part") then
if v.Locked == true then
print("bye")
v:Destroy()
else
return
end
end
end
Report Abuse
championbuilder is not online. championbuilder
Joined: 20 Jan 2009
Total Posts: 13544
14 Mar 2015 06:09 PM
I tried BasePart, and "if blaj and bsahj then", but:

BasePart is nil cause of Terrain.

and it just comes up nil with the and.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Game Design
   
 
   
  • 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