I have a strange problem occuring with GetChildre() and MouseButton1Up

I’ve worked on roblox studio on this thing I wanted to try out and I’ve ran into problems before related to this but fixed it. This time the problem is pretty weird. Depending on the amount of buttons, if they are more than 2 it starts breaking.
I’ve created these buttons with instance.new in a seperate for loop. I don’t know if that changes anything.


If there are 2 buttons it works. If there are 3 buttons the first one fires once, 2nd one fires 2 times, 3rd one doesn’t fire when clicked. If there are 4 the first one fires once, the second one fires 3 times, 3rd one doesn’t fire, and 4th one fires once when clicked.

Heres my code.

Why have you got a MouButton1Up function in a loop? – That wont work!

1 Like

what do you mean? It does kind of work. I need to put the MouseButton1Up in a for loop so that I can get the buttons when they trigger with GetChildren().

Any roblox even will create a new thread that waits for the event to fire, and it will fire multiple times if triggered accordingly. You do not need to put an even in a while loop.

Edit: Just realized you put it in a for loop not a while loop. In this case the use may be justified :sweat_smile:

Its cool. When I did some checking with prints I found when I did print(v) that if there were 3 buttons then one button would print once, one would fire twice, and the other would not print at all. Could this be a problem with GetChildren()?

It seems like I fixed it somehow on accident or something I don’t really remember. I just remember putting wait statements down and such.