I am trying to make the same function occur on different triggers basically. Currently I have something like this within a GUI Button:

function onClicked(GUI)
	--code
end
script.Parent.MouseButton1Click:connect(onClicked)

Can I just add connect statements to this for other GUI buttons in the game like this?

function onClicked(GUI)
	--code
end
script.Parent.MouseButton1Click:connect(onClicked)
game.workspace.otherButton.MouseButton1Click:connect(onClicked)
game.workspace.otherButton2.MouseButton1Click:connect(onClicked)

2 comments

1

I think so, but I might be wrong.

1

That's it! As long as the RBXScriptSignal is valid, you can Connect any function. Please ensure you're using a capital C though, lowercase :connect() is deprecated.