local Folder = PathToFolder
Folder.ChildAdded:Connect(function()
if #Folder:GetChildren() == 0 then
end
end)
Folder.ChildRemoved:Connect(function()
if #Folder:GetChildren() == 0 then
end
end)
this should run if a child is added or removed from the folder, if you want to easily do this to any folder with less code then do this
local Folder1 = PathToFolder1
local Folder2 = PathToFolder2
function CheckFolder(Folder)
Folder.ChildAdded:Connect(function()
if #Folder:GetChildren() == 0 then
end
end)
Folder.ChildRemoved:Connect(function()
if #Folder:GetChildren() == 0 then
end
end)
end
CheckFolder(Folder1)
CheckFolder(Folder2)
either way don’t do the second option if you only need to do one folder
also if you want to do the second option just use a module script to make it look cleaner
-- Folder Path
local Folder = game:GetService("Workspace"):FindFirstChild("Folder")
-- Inside The Folder Which Is The Parts.
local PartInside = Folder.PartInside
-- Remove The PartInside Before We Begin To Check.
wait(1)
Folder:ClearAllChildren()
-- Or You Can Do Specific But Does Not Remove All Parts.
PartInside:Destroy()
if #Folder:GetChildren() == 0 then
-- Code Here
-- Example Code:
Instance.new("Part").Parent = Folder
-- We just added a new part to the Folder.
end