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

ClickDetector in a gui?

Asked by 8 years ago

Is it possible to put a click detector in a screengui button to find the player who clicked?

1
No User#11440 120 — 8y
0
Just use a textbutton Kryddan 261 — 8y

1 answer

Log in to vote
1
Answered by 8 years ago

I don't know if it's possible, but it's not necessary. To get the player who clicked the button, all you'd need is the proper Event.

Assuming you want to find the player who clicked your GUI with the left mouse button, just use the MouseButton1Down() or MouseButton1Click events in a localscript. Here's an example:

local GUI = script.Parent --Assume the localscript is located in the GUI Button.

GUI.MouseButton1Click:connect(function(player) --player is the player who clicked it.
    print(player.Name) -- Prints player's name into the output. Remember, this is sample code, so this is just an example.
end)

Hope this helps, and if you have any questions lemme know. :)

Ad

Answer this question