I have this...
for _,buttons in pairs(script.Parent.Inventory:GetChildren()) do buttons.MouseButton1Click:connect(function() print("clicked") end) end
My inventory frame has all the slots and everything but there is also a 'UIGridLayout' in it too, so everytime i try running this, it comes up with this error:
08:46:12.334 - MouseButton1Click is not a valid member of UIGridLayout.
Is there a way I can ignore the UiGridLayout and how? I really do appreciate your help!
Try checking if the object is a button, and then put in your MouseButton1Click function like so:
for _,buttons in pairs(script.Parent.Inventory:GetChildren()) do if buttons:IsA("TextButton") then --if the button is a text button, if its an image button put in "ImageButton" buttons.MouseButton1Click:connect(function() print("clicked") end) end end