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

Who clicked my TextButton?

Asked by 8 years ago

I have a textbutton on an object in the world which I'm binding MouseButton1Clicked events to. How do I tell who clicks it?

0
It's a simple question, but one which most people using textbuttons will run into, and there is no indication of how to do it in the documentation I've been able to find so far. Brouhahaha 27 — 8y

2 answers

Log in to vote
2
Answered by
Pyrondon 2089 Game Jam Winner Moderation Voter Community Moderator
8 years ago

As the SurfaceGui wiki page says, SurfaceGuis must be descendants of PlayerGui in order to know the player who is interacting with it.

Your best bet would be to put the GUI inside of each player's PlayerGui, and set the Adornee to the original object.

Hope this helped.

0
I though everyone knew that. Probably needs to watch a few tutorials. Meltdown81 309 — 8y
0
Ah thanks. It's a bummer. Right now I have clickable bricks, with sGuis on them explaining what each one does. I was hoping that I could just add a TextButton to the sgui instead of the current TextLabel's i'm using, and then get rid of clickdetectors. (The goal being to make only one face of the brick clickable instead of the whole thing) Brouhahaha 27 — 8y
Ad
Log in to vote
0
Answered by 8 years ago
-- Wherever your text button is
workspace.TextButton.MouseButton1Down:connect(function(Player)
    local PlayerName = Player.Name
end)

That code will give you the name of the player who clicks the button.

0
No, it wouldn't. The MouseButton1Down event passes the x and y positions of where the input occurred as arguments, not the player. http://wiki.roblox.com/index.php?title=API:Class/GuiButton/MouseButton1Down Pyrondon 2089 — 8y
0
Oh, jeez whoops. Was thinking ClickDetectors XD my bad. (Not much of a GUI person) Lord_Hagenost 40 — 8y

Answer this question