of     1   

MasterDaniel
#141053605Monday, July 21, 2014 1:43 PM GMT

Hi 'dere! I was wondering if its possible for several textbuttons to fire the same event and run the same function without me needing to put the script in 30+ buttons: Code: function onClick() script.Parent.Parent.Parent.Parent.Loading.Visible = true end script.Parent.MouseButton1Click:connect(onClick) I want this to be executed when any of the buttons are clicked but there must be a more efficient way than pasting this in every TextButton?
wish_z
#141053701Monday, July 21, 2014 1:45 PM GMT

for i,v in ipairs(script.Parent:GetChildren()) do if v:IsA("TextButton") then v.MouseButton1Click:connect(function() script.Parent.Parent.Parent.Parent.Loading.Visible = true end) end end
MasterDaniel
#141053869Monday, July 21, 2014 1:48 PM GMT

The buttons are all called different names :/ I was thinking - is it possible to put the function in a Module and then call it from each button? I began to do this but couldn't go any further when I put script.Parent and realised that this probably wouldn't work as its not in the GUI?
wish_z
#141054051Monday, July 21, 2014 1:52 PM GMT

It doesn't matter if their different names. If they ALL have the same parent, that would work.
MasterDaniel
#141056497Monday, July 21, 2014 2:30 PM GMT

Ahh okay. I tried it but it doesn't work. I put it inside a Frame with several TextButtons. Don't worry about it too much I might be able to do without it anyway

    of     1