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

Not take away Terrain from Workspace?

Hello, I'm a making a holographic training center. The script below is suppose to end the maps. (Remove them.) However I am having trouble with the Terrain child. Please help!

elseif message == "!end" then
for i,v in pairs(workspace:GetChildren()) do
if  v.Name ~= "Terrain" or "Lobby" or "Player" then
v:destroy()
	end
end

This script should take away every child of Workspace besides the Terrain, Players, and Lobby. But however the output always comes up with the same error.

19:54:50.142 - Cannot Destroy() Terrain

Please help!

1 answer

✓ Accepted answer
for index, child in pairs(workspace:GetChildren()) do
	if child.Name ~= "Terrain" or child.Name ~= "Lobby" or child.Name ~= "Player" then
		child:Destroy()
	end
end

I recommend using models instead of deleting workspace's childs.

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