Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does a Script and a LocalScript not work on a Surface GUI's Button?

I am on tablet so I am not doing good, but on my computer I have a button and I use the script below in the button. Now I tried both Localscript and Script, but neither of them work! The script works in studio mode, but not in player mode. This is a cool thing to my game crop farm tycoon with this you use it as the tycoon button, and you use another one to change the hover color! PLEASE HELP!

And remember that THIS IS A SURFACE GUI WITH A BUTTON INSIDE OF IT! just to not make a mistake and redo it xD

script.Parent.MouseButton1Click:Connect(function(onClick)
     script.Parent.Parent.Visible = false --Just an example not the real thing onClick...
end)

2 comments

0

try deleting the "onClick" which isn't actually a name for your function, rather a parameter (which the event "MouseButton1Click" does not send any)

0

As it works in game but not in studio, try making all of your variables local?

2 answers

Change :Connect to :connect. Roblox maybe is case sensitive so it may works. If it doesn't work, then check the thing that you're telling the script to do, it maybe the cause of the problem.

1 comment

0

Yeesh all these answers 2 years ago and none of you are even close to right...

Remove the "OnClick" because there is no reason for it to be there. The mousebutton1click event doesn't have any parameters.

1 comment

0

There's no reason to remove it. You could name the function anything you want, the name doesn't matter and doesn't affect anything in the script.

This discussion is preserved as it was. New answers, comments, and votes are closed.