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

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

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

0

yes

0

findFirstChild and connect are deprecated use FindFirstChild and Connect

0

@inca did not fix it, still error.

1 answer

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