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

[SOLVED]How would I make this BackgroundColor3 script apply to all children?

How would I make this BackgroundColor3 script apply to all children?

I have tried to do it.. and failed. Currently it only works for a Child it finds named "Store"

How would I re-code it so that it applies to all children?

Any help is greatly appreciated!

Here is the coding:

for i,v in pairs(script.Parent:GetChildren()) do
	if v.Name ~= "Script" then
		if v.Name == "Store" then
			v.MouseEnter:connect(function()
				v.BackgroundColor3 = Color3.new(255,0,0)
			end)
		end
	end
end

2 answers

I'm probably the worst person you should take advice from but you could iterate through all children with a for loop and getchildren() and match it with certain properties and then change the backgroundcolor3 of all of children that were achieved from the for loop/getchildren() and set it.

1 comment

0

Thank you for you help, but I figured out how to do it. :)

for __, obj in next, (script.Parent:GetChildren()) do
	if obj:IsA('GuiObject') then
		obj.MouseEnter:connect(function()
			v.BackgroundColor3 = Color3.fromRGB(255,0,0) -- or Color3.new(255/255,0/255,0/255)
		end)
	end
end

:: Run from a local script

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