local arrayFrame = script.Parent.ArrayFrame -- The array
for i, v in pairs(arrayFrame:GetChildren()) do -- Get the children from the array, then loop through all the buttons and check if the button has been pressed. The I is the index, the v the actual object.
if v:IsA("TextButton") or v:IsA("ImageButton") then -- Check if the object is an actual button
v.MouseButton1Click:Connect(function() -- When a player clicked the button then this even twill fire
-- Do stuff
end)
end
end