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

How to delete selection boxes?

Asked by 10 years ago

So I'm making this plugin where it turns all the bricks into outlines with the use of selection boxes. My problem is that when I go to reverse the function, it doesn't delete all the selection boxes, only a few of them. Please help!

for _, v in ipairs(game.Workspace:GetChildren()) do
    if (v.ClassName == "Part") or (v.ClassName == "WedgePart") then
        v.Transparency = 1  
        local Part = v
        local box = Instance.new("SelectionBox", v)
        box.Adornee = Part
        box.Color = BrickColor.new("Really black")
    end
end

for _, v in ipairs(game.Workspace:GetChildren()) do
    if (((v.ClassName == "Part") or (v.ClassName == "WedgePart")) and (v.Transparency == 1)) then
        v.SelectionBox:remove()         
        v.Transparency = 0
    end
end

Answer this question