for i,Buttons in pairs(Gui:GetChildren()) do for i,v in pairs(Buttons) do v.MouseButton1Click:connect(function() print(v) end) end end --bad argument #1 (table expected, got Object)
My Gui has 2 objects, shirt and pants but for some reason it gives out only "Shirt" so it doesn't creates table and gives out that error. Don't know what causes this problem
Are you sure you need the second for i, v.
for i,Button in pairs(Gui:GetChildren()) do Button.MouseButton1Click:Connect(function() print(Button.Name) end) end