Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What is wrong with this script?

Asked by
IcyEvil 260 Moderation Voter
10 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

I tried out i,v in pairs finally And It messed up...

for i,v in pairs(game.Workspace:GetChildren()) do
    v:remove() -- [[ Error| The Parent Property of Workspace.Terrain is locked. current parent:Workspace.new parent NULL ]]
end

1 answer

Log in to vote
1
Answered by
Sublimus 992 Moderation Voter
10 years ago

The Terrain object is RobloxLocked, meaning it cannot be removed. To get around this and other objects that are RobloxLocked, use this:

for i,v in pairs(game.Workspace:GetChildren()) do
    if v.RobloxLocked == false then
        v:Destroy() -- Use :Destroy(), :remove() is deprecated.
    end
end
Ad

Answer this question