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

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

Asked by
nanaluk01 247 Moderation Voter
7 years ago
Edited 7 years ago

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

Log in to vote
0
Answered by 7 years ago

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.

0
Thank you for you help, but I figured out how to do it. :) nanaluk01 247 — 7y
Ad
Log in to vote
0
Answered by 7 years ago
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

Answer this question