Is there a way to add arguments into MouseButton1Click connection when function is a variable?

For example, if you have a few MouseButton1Click connections and they use only one function:

For now, to add variables i activate function on mouse click and then another one. I feel like this is bad.

No, you can’t add arguments along :Connect(). Don’t worry, I know it’s one more function, but it’s no big deal.

The more important thing in your code would be to wait for the GUI elements to load.

image

In this image, script.Parent definitely exists, but there’s no guarantee that Frame and ImageLabel are already cloned under PlayerGui by the time script runs. So use :WaitForChild(), best with the elements saved in variables. Cloning time is not a problem for small GUIs, but the more elements you have, the more likely you’ll run into an error.

2 Likes

So you want to pass additional arguments onto the function alongside the parameters in the Connect?

Ah, anyway, thanks for the info

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.