Remove all members of a folder except a few?

How could I remove everything in a folder except a select few? I tried something like this:

for i, Remove in pairs(Folder:GetChildren()) do
			if Remove.Name ~= PlayerData.Player or Remove.Name ~= PlayerData.Partner then
				Remove:Remove()
			end
		end

But it didn’t really work.

local WhiteList = {
"Name"
}

for i,v in next, Folder do
    if not table.find(WhiteList,v.Name) then
        v:Destroy()
    end
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.