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

Not take away Terrain from Workspace?

Asked by
PixelYT 30
9 years ago

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

Log in to vote
0
Answered by 9 years ago
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.

Ad

Answer this question