Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Could I change every child's transparency with one line?

Could I change the transparency of every child part of a model using one line of code using GetChildren or something as long as all the children have the same name??

For example I tried this

local c = game.Workspace.Model:GetChildren("Part")
wait(5)
c.Transparency = 1

the above code didnt work

1 answer

✓ Accepted answer

A function.

function changeAllChildProperties(parent, type, property, value)
    for _, v in next, parent:GetChildren() do
        if v:IsA(type) then
            v[property] = value
        end
    end
end

changeAllChildProperties(workspace.Model, "BasePart", "Transparency", 1)

This discussion is preserved as it was. New answers, comments, and votes are closed.