|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|