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

Is it possible to apply function to all children of a GUI?

Asked by
nek_oo 2
5 years ago

Here's my script:

local plr = game.Players.LocalPlayer
local name = script.Parent.Parent.Parent.Name
for i, v in pairs(script.Parent:GetChildren()) do
    local morph = plr.Character:findFirstChild("HeadParts")
    local clr = script.Parent.BackgroundColor3
    for i, c in pairs(morph:GetChildren()) do
        if c.Name == name then
            c.Color = clr
        end
    v.MouseButton1Click:connect(function()
        head()
    end
end

basically, I'm supposed to click a color on a GUI, and it changes the colors of a morph. I don't want to add the same script to every single color option due to lag, so is it possible to apply a function to all options with one script? I'm a big noob, not very good with functions and stuff.

0
yes User#19524 175 — 5y
0
findFirstChild and connect are deprecated use FindFirstChild and Connect User#19524 175 — 5y
0
@inca did not fix it, still error. nek_oo 2 — 5y

1 answer

Log in to vote
0
Answered by
nek_oo 2
5 years ago

bump...

Ad

Answer this question