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

OnClick function for GUI text button not working?

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

✓ Accepted answer

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)

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

8 comments

0

Awesome, thank you!

0

Still not working. The entire "mousebutton1down" function seems to just not work.

0

Where have you put the script?

0

local script, by itself in the playergui folder

0

startergui*

0

I just tried it and it worked fine, I put the script in the same place and everything.

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

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

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