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

How do I check when a gui's button is clicked?

Asked by
DemGame 271 Moderation Voter
4 years ago

How do I check when a button inside of a GUI is clicked? The scripts from ROBLOX's website don't work for some reason.

0
Post the Script please JB_SuperGamer 165 — 4y
0
Um... I don’t have a script for the GUI related to clicking a button yet... DemGame 271 — 4y
0
I do have two text buttons inside of a frame and a text label though. DemGame 271 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

You need a TextButton or an ImageButton to register a MouseButton1Click or MouseButton1Down event. Put a script in your TextButton/ImageButton and paste the following code.:

script.Parent.MouseButton1Click:Connect(function() -- Attach a function to your MouseButton1Click RBXScriptSignal
    -- Your code here.
end)
0
Tiny correction, make sure it's a LocalScript because a script wouldn't detect it as well as GUIs are only on the client. uhi_o 417 — 4y
0
true FunctionalMetatable 490 — 4y
0
true FunctionalMetatable 490 — 4y
0
Thanks. DemGame 271 — 4y
Ad

Answer this question