Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago

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)
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) creeperhunter76 554 — 6y
0
As it works in game but not in studio, try making all of your variables local? T0XN 276 — 6y

2 answers

Log in to vote
0
Answered by
LeadRDRK 437 Moderation Voter
6 years ago

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.

0
Yeesh all these answers 2 years ago and none of you are even close to right... Psudar 882 — 4y
Ad
Log in to vote
-1
Answered by
Asceylos 562 Moderation Voter
6 years ago

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

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. LeadRDRK 437 — 6y

Answer this question