How to delete half of the children in a instance inside a local script

Hey i was wondering how i could delete half of theese.


inside a local script.
So only one player could see it destroyed

In a local script:

local Folder = -- Path to folder here
local Children = #Folder:GetChildren()

local NumToDelete = math.round(Children / 2)

for i = 1, NumToDelete do
  Folder:FindFirstChildOfClass("Part"):Destroy()
end

Try this.

1 Like
local folder = workspace:WaitForChild("Folder")

for index, part in ipairs(folder:GetChildren()) do
	if part:IsA("BasePart") then
		if math.random() <= 0.5 then
			part:Destroy()
		end
	end
end

For random deletion.

1 Like