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

i used clearallchilderen but terrian cant be removed by clearallchildren how to fix this?

local remoteevent = game.ReplicatedStorage.ResetServer

local function ResetServer()
	game.Lighting:ClearAllChildren()
	game.Workspace:ClearAllChildren()
	game.StarterPack:ClearAllChildren()
	game.ServerStorage.Baseplate:Clone().Parent = workspace
end

remoteevent.OnServerEvent:Connect(ResetServer)

so i wanna clear all childern of workspace exepct train because that cant be cleared but how can i get around this issue

4 comments

0

a quick google search results in: game.Workspace.Terrain:clear()

0

i dont want to clear the trerrian i want to clear everything but the terrian

0

then just loop through everything in the workspace and if it isn't named terrain delete it

0

how would i do that?

1 answer

✓ Accepted answer

To loop through everything in the workspace and delete everything but the terrain you might do something like this, forgive me if this isn't exact right, I haven't coded using Lua in quite some time

for i,v in pairs(workspace:GetChildren()) do
	if v.Name ~= "Terrain" then
		v:Destroy()
	end
end

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