How to delete all locked parts?

I have a game that has alot of things locked, but I just want to keep the unlocked parts. How would I be able to do this using console commands?

for i,v in workspace:GetDescendants() do -- iterates through all of workspace
    if v:IsA("BasePart") and v.Locked then -- checks if Item is a Part and Locked
        v:Destroy() -- Destroys Part
    end
end

Am I missing something?


I don’t think you made a problem, I think I did. Is this how I am supposed to place it in the console bar? It seemingly doesn’t work.

Command Bar is just a Column, so do this I guess:

for i,v in workspace:GetDescendants() do if v:IsA("BasePart") and v.Locked then v:Destroy() end end

Basically you are commenting out the code, i think thats whats wrong

1 Like

I think it will still work with those comments, it just doesn’t highlight correctly.

I modified it alot but the script itself works. Thank you!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.