This works fine:
button = script.parent function click() print("hello") end button.MouseButton1Click:connect(click)
but this doesn't work?
function click() print("hello") end game.StarterGui.ScreenGui.TextButton.MouseButton1Click:connect(click)
This doesn't work too...
game.StarterGui.ScreenGui.TextButton.MouseButton1Click:connect(function (click) print("hello") end)
in examples 2 and 3 script was not a child of the button TY
Simple answer --> No
So.. what's the problem then? --> Answer: You're forgetting that startergui gets cloned to the playergui, the startergui buttons will never get clicked!
Also, remember your scripts need to be local scripts inside client areas.
(The best way to do what you want to do is using script.Parent.Parent.Button for example, as these won't change if it gets cloned)