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

How to change a property of all children in a Folder?

Asked by 6 years ago
Edited 6 years ago

I want to make all children of the map Transparency = 0 when someone touches a brick

script.Parent.Touched:Connect(function(hit)

    if hit.Parent:FindFirstChild("Humanoid") then

        script.Parent.Parent:GetChildren().Transparency = 0
    end
end)

The LocalScript is in a Part which is in the Folder.

0
loop over the children gullet 471 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

you can use a for loop which literates through a table, so you can use :GetChildren() as it returns a array or well a table and use the variable.

local descendants  = script.Parent.Parent:GetChildren() -- define where all the children are

for _,v in pairs(buttons) do -- "v" can be named anything
    print(v.Name) -- prints each item's name; just an example

    -- stuff
end
0
I don't need this script anymore, but your script should work so I'll accept your answer because you helped, although I don't need it anymore Spjureeedd 385 — 6y
Ad
Log in to vote
-1
Answered by 6 years ago
script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        for i,v in pairs(script.Parent.Parent:GetChildren()) do
                 v.Transparency = 0
          end
    end
end)
0
Nope, doesn't work Spjureeedd 385 — 6y
0
What is the script gonna do? Lava_Scripter 109 — 6y

Answer this question