When a player clicks a TextButton, it sets off a function, but how do I target the player who clicked that GUI button?
✓ ANSWER ACCEPTED
How to target the player that clicked?
2 answers
✓ Accepted answer
You can use a local script to define the player as so: plr = game.players.LocalPlayer
Are you using a SurfaceGui? If so, parent the SurfaceGui to StarterGui, and make the Adornee the part you want it to be on (with a script inside the SurfaceGui). Then, using a LocalScript, detect when they click the button with MouseButton1Down (use a LocalScript because you can use Game.Players.LocalPlayer).
This discussion is preserved as it was. New answers, comments, and votes are closed.

8 comments
But can't there be only one Local Script per a game because it makes the person that has it the LocalPlayer? (sorry if I'm wrong, I've never used them before).
There can be many local scripts. The Local Player is kind of omnipresent. It can be used for anyone in multiple scenarios.
And I got downed..
So if I put two LocalScripts in two different people, and then used a function to kill the LocalPlayer, who would die?
P.S. It wasn't me who downed you.
Well, you wouldn't need to parent the script to the player. You'd have it in Workspace or StarterGui. If you have a kill function in both of them, both will die. Think of it as just saying game.Players.shawnyg.
Oh, so when people have LocalScripts the game run each of them seperately for each person and targets the person playing? I think I get it now. Thanks!
Yes, you are correct!