So I am trying to delete everything in workspace that is a model but keeping some of the models. I used names. This is the script I tried before. [All of them dont actually say name, that is just an example]
for i, v in pairs(game.Workspace:GetChildren()) do if v.ClassName == "Model" then if v.Name ~= "name" or "name" or "name" or "name" or "name" or "name" or "name" or "name" or "name" or "name" or "name" then --print(v.Name) end end
Could anyone help? Thanks
This is so wrong, between each 'or' you should say if v.Name ~= "name". Like for example:
for i, v in pairs(game.Workspace:GetChildren()) do if v.ClassName == "Model" then if v.Name ~= "name" or v.Name ~= "name" or v.Name ~= "name" then --print(v.Name) end end
Your way of adding ors everywhere isn't very efficient, I think you should use tables instead, as it saves more time, you just need to type a comma then a string, like this:
ignore = {'name','name2','name3'} for i, v in pairs(game.Workspace:GetChildren()) do if v.ClassName == "Model" then if isInTable(ignore,v.Name) then --print(v.Name) end end function isInTable(tab,thing) for i = 1,#tab do if tab[i] == thing then return true end end end