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

How would I define the children of a parent?

Asked by
Resnex 60
10 years ago

This is a snippet of a script, and it doesn't seem to work. Help!

script.Parent.Children.Transparency = 1

It says that Children isn't defined!

1 answer

Log in to vote
2
Answered by 10 years ago

If you wanted all the children of a parent to have a transparency of 1, this is how you would do it:

local Children = script.Parent:GetChildren() --GetChildren() returns a table containing all the children of the parent
for _,v in pairs(Children) do --This is a "special" for loop that iterates through every element of a table
    if v:IsA("BasePart") then --If the child is a part...
        v.Transparency = 1
    end
end

Hope this helped!

Note: If you still have trouble with GetChildren(), click here: GetChildren()

Ad

Answer this question