Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

What is wrong with this script?

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.