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.

3 comments
yes
findFirstChild and connect are deprecated use FindFirstChild and Connect
@inca did not fix it, still error.