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

OnClick function for GUI text button not working?

Asked by
Smunkey 95
8 years ago

I found the problem... For some reason it refused to work in my textbutton, but when I deleted it and put in a new text button with the same script it worked perfectly.

2 answers

Log in to vote
0
Answered by 8 years ago

This is how I do it

Open = false
script.Parent.Mousebutton1Click:connect(function()
Gui = script.Parent.Parent.NAMEOFYOURGUI
--Just an example, if I wanted the shop to open when clicked
if Open == false then
Open = true
elseif Open == true then
open = false
end
end)

Ad
Log in to vote
0
Answered by 8 years ago

For GUI's you do not use click detectors like you would in a part, instead you would use:

script.Parent.MouseButton1Down:connect(onClicked)

This triggers when the left mouse button is pressed.

Make sure the script is inside the button rather than the click detector when you fix it!

Take a look at this:

http://wiki.roblox.com/index.php/Beginner's_GUI_Tutorial#Buttons

0
Awesome, thank you! Smunkey 95 — 8y
0
Still not working. The entire "mousebutton1down" function seems to just not work. Smunkey 95 — 8y
0
Where have you put the script? MaskedVoid 15 — 8y
0
local script, by itself in the playergui folder Smunkey 95 — 8y
View all comments (4 more)
0
startergui* Smunkey 95 — 8y
0
I just tried it and it worked fine, I put the script in the same place and everything. MaskedVoid 15 — 8y
0
Wait, it doesn't need something like 'script.Parent.MouseButton1Click:connect(onMouseClick)' type of deals on the bottom does it? Because the wiki mentions nothing of the sort Smunkey 95 — 8y
0
I noticed I had it way down at the bottom of the list of gui parts and not directly in the folder, my bad. But I need it to work without creating new instances but I can't figure out how :l Smunkey 95 — 8y

Answer this question