Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how make a script ignore everything in a table?

Asked by 2 years ago

script and title should probably explain

local settings = require(script.Parent.Parent.ModuleScript)

script.Parent.MouseButton1Click:Connect(function()
    script.Parent.Parent.CanvasPosition = Vector2.new(settings.frame[script.Parent.Name])
    for i,names in pairs(settings.ignore()) do
        for i,v in pairs(script.Parent.Parent:GetChildren()) do
            if v.Name ~= names and v.Name ~= script.Parent.Name.."".."Song" then
                v.Visible = false
            end
        end
    end
end)

the for i script is the one not working but i don't understand why

1 answer

Log in to vote
1
Answered by 2 years ago

If your blacklist is a simple array then you're going about it wrong. If you want to check whether a part's name is in a table it should go like this:

local IgnoreList = { "Torso", "Head", "Left Leg" }

for i,child in pairs(Character:GetChildren()) do
    if not table.find(IgnoreList, child.Name) and not child.Name == script.Parent.Name.." ".."Song" then
        child.Visible = false
    end
end
Ad

Answer this question