|
How do I make a script that deletes everything in the workspace, serverstorage, serverscriptstorage, replicatedstorage, and startergui |
|
|
why
╴ “I seem to get mentioned alot in videogames.. i wonder why..” |
|
DivitiaeJoin Date: 2017-06-26 Post Count: 166 |
workspace = game.Workspace:GetChildren()
for i,v in pairs(workspace) do
v:Destroy()
end
|
|
Kiriot22Join Date: 2015-07-19 Post Count: 226 |
for i,v in pairs(workspace:GetChildren()) do pcall(game.Destroy, v) end
|
|
amandaJoin Date: 2006-11-21 Post Count: 5925 |
clearallchildren |
|
|
you cant destroy terrain so i believe that would error my guy
╴ “I seem to get mentioned alot in videogames.. i wonder why..” |
|
DivitiaeJoin Date: 2017-06-26 Post Count: 166 |
asgw = game.Workspace:GetChildren()
for i,v in pairs(asgw) do
if v.Name ~= "Terrain" and v.Name ~= "Camera" then
v:Destroy()
end
end
|
|
DivitiaeJoin Date: 2017-06-26 Post Count: 166 |
^ this will work, i tested it
|
|
Kiriot22Join Date: 2015-07-19 Post Count: 226 |
function Clear(services)
for _,v in pairs(services) do
local service = game:GetService(v)
for _,v in pairs(service:GetChildren()) do
pcall(game.Destroy, v)
end
end
end
Clear({"Workspace", "ServerStorage", "ServerScriptService", "ReplicatedStorage", "StarterGui"})
Although clearing ReplicatedStorage is a bad idea, since chat remotes are stored there.
|
|
|
oml no need for loops just use
workspace:ClearAllChildren()
serverstorage:ClearAllChildren()
etc |
|
|
using ClearAllChildren on workspace will error because it will try to destroy terrain
|
|
DivitiaeJoin Date: 2017-06-26 Post Count: 166 |
^
|
|
LuckyxeroJoin Date: 2014-02-26 Post Count: 505 |
for i, v in pairs(workspace:GetChildren()) do
if v.Name ~= "Terrain" then
v:Remove()
end
end |
|
Kiriot22Join Date: 2015-07-19 Post Count: 226 |
Remove() is deprecated
|
|
DarkLightJoin Date: 2006-12-04 Post Count: 22 |
local DestroyAllChildren = function(...)
for i, v in pairs(unpack(...)) do
pcall(game.Destroy, v)
end
end
DestroyAllChildren(workspace, game:service'ServerStorage', game:service'ReplicatedStorage', game:service'StarterGui') |
|
LuckyxeroJoin Date: 2014-02-26 Post Count: 505 |
wow he joined in 2006 |
|
Kiriot22Join Date: 2015-07-19 Post Count: 226 |
You can't use unpack() on ... as it's already "unpacked"
|
|