Events but for multiple items?!

I am going to just use a simple example to convey my problem.

lets say i have 3 parts in this small senario. and i want to have lets say it to turn a color based off of its name. and i only want to controll this from one script. doing soo i would have this ugly out come of


SomeRandomPart.touched:connect(SomeFunction)
SomeRandomPart.touched:connect(SomeFunction)
SomeRandomPart.touched:connect(SomeFunction)

now lets say i have 30 of these also changing at the same time i cannot manually type these all out so how can i go about this? in my case i have multiple frames in a grid layout and i want it that every time one of those frames are clicked the assigned frame gives you its tool then deletes, but there a lot of frames

for i,v in pairs(ParentOfThoseParts:GetChildren()) do 
	v.Touched:Connect(function(Hit)
		print("hi")
	end)
end
1 Like

I tried this technique but I dont know what you have done is the wrong part for my situation or im just dumb :sob:

local function InputCheck(Chest)
	local UIClone = Chest.UI:WaitForChild("ChestGui")
	for _, Frame in pairs(UIClone.Main:GetChildren()) do
		if Frame.Name == "UIGridLayout" then continue end
		print(Frame) -- only prints this nothing else
		Frame.InputBegan:Connect(function(Input)
			print("woah") -- no print
			if Input.UserInputType == Enum.UserInputType.MouseButton1 or Input.UserInputType == Enum.UserInputType.Touch then			
				if Frame.Name == "Delete" then
					Event:FireServer("Delete")
					print("youch")-- no print
				else
					print("Yipee")-- no print
					Event:FireServer(Frame.Text.Text)
				end
			end
		end)
	end
end

could the order of my UI layout be a hinderence?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.