Basically, is there a method to delete all children in workspace with the same name. I am trying to make a tycoon regen script and i want to delete all BcopperIngot, BIroningot and bCopperOre that is currently in workspace. If there is not a method how would i be able to do it?
local m = game.Workspace:GetChildren() for i, v in pairs (m) do if v.Name == "name" then v:Destroy() end end)
yes i tested this and it worked, and you said remove so ill :Destroy() it
You can do what @KardashevScale said in the comments, I am going to give some examples of you could do. First one is what Kardashev said:
for i, v in pairs (workspace:GetChildren()) do if v.Name == "IDK" then v:Destroy() end end
Another way is to add the items with the same name in a folder and do workspace.Folder:ClearAllChildren()
.
Those are the 2 most efficient ways, pick the one you think is the best.