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

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

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.

1 comment

0

loop over the children

2 answers

✓ Accepted answer

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

1 comment

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

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)

2 comments

0

Nope, doesn't work

0

What is the script gonna do?

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