How to check events for multiple objects without copy and pasting

Hello!

For the past 2 days I was working on a plugin, and I was making these properties, the properties are a frame instance, and all of them have Input child as an instance. How could I make this actually working.


Script:

Parameters:GetChildren().Changed:Connect(function(a)
	for _, parameter in pairs (Parameters:GetChildren()) do
		if parameter:IsA("Frame") then
			Settings.Themes:SetAttribute(parameter.Name, parameter.Input.Text)
			print(Settings.Themes:GetAttribute(parameter.Name))
		end
	end
end)

THE SCRIPT IS NOT WORKING BY THE WAY


The attributes are all fine, but if there’s something I could replace them with and will be easier/better to work with please tell me the method.

Every of the events that happen will do the same thing anyways.

Thank you!

The result of GetChildren() is a Table. You need to loop through that table to get the Changed property for each child.

Hey, sorry for a late reply, I’m trying to get an event from the children at once, how would I do that? This was basically the issue.

What you could do is just loop over those parameters and then get it’s name, and then adjust the attributes depending on the values. So that means you have to loop. You can also make your own special class in lua for inserting events into array of objects, so you can handle that pretty nicely.
like

 insertEventIntoObjects(EventName:string,Function,Objects)
 --reference event by doing the Object[EventName] trick and then connect it
1 Like

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