Hello, is there a way i can delete everything that is called the same name in a script?
for example, i have everything as decal, i don't want to delete it manually, Is there a way?
local asdnew = Instance.new("TextButton",ScreenGui) asdnew.BackgroundColor3 = Color3.new(0,0,0) asdnew.BorderColor3 = Color3.new(0,0,0) asdnew.Name = "nooties" asdnew.Position = UDim2.new(1,-150,1,-90) asdnew.Size = UDim2.new(0,150,0,45) asdnew.Font = "SourceSansBold" asdnew.FontSize = "Size14" asdnew.Text = "Destroy" asdnew.TextColor3 = Color3.new(255,255,255)
asdnew.MouseButton1Click:connect(function() game.Workspace.Sound:Destroy() game.Lighting:Destroy() game.Workspace.Terrain:Destroy()() game.Workspace.Camera:ClearAllChildren()() game.Workspace._CPData:ClearAllChildren()
Hello, TheEdyGamerTroll23!
This script will destroy everithing with the names on table that are on workspace!
local DestroyList = {"ThingOne","ThingTwo"} -- Things name to destroy here(!!Just From Workspace!!) local DestroyDescendants = {"ThingOne","ThingTwo"} -- Things name to destroy here(!!!From Workspace and its Descendants!!!) function Destroy() for _,Object in pairs(game.Workspace:GetDescendants()) do for _,WorkspaceItem in pairs(DestroyList) do for _,Descendants in pairs(DestroyDescendants) do if Object.Name == WorkspaceItem then Object:Destroy() -- Destroys Workspace items end if Object.Name == Descendants then Object:Destroy() -- Destroys Childs of Items =D end end end end end Destroy() -- Calls the function to destroy the parts in workspace!
Read the comments!
This script will destroy when you PLAY the game, parts will still be in studio
Good Luck with your games!
local itemName = "ENTER ITEMNAME" --enter name of item here local item = game.Workspace:FindFirstChild(itemName,true) while item do item:Destroy() item = game.Workspace:FindFirstChild(itemName,true) end
it's slow but it works :D
or loop over everything
local function destroyAll(list) for index, child in pairs(list) do if child.Name == "ENTER NAME HERE" and child:IsA("Decal") then --enter item info here child:Destroy() else destroyAll(child:GetChildren()) end end end destroyAll(game.Workspace:GetChildren())
allows you to check the item type and is much faster if you have lots of stuff.. ALL CODE UNTESTED bugfix for yourself