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

Can you get player by clicking surfacegui/button?

Can you get the player when he clicks a surfacegui.TextButton?

1 answer

✓ Accepted answer

Not if it is in Workspace
In order to get the Player that is using a TextButton on a SurfaceGui, the SurfaceGui in question needs to be in the Player's PlayerGui and Adorned to the target surface. If the SurfaceGui is in the PlayerGui, you can use this little snippet to get the Player it's in automatically.

local player = script;
repeat player = player.Parent until player.Parent = game.Players

That will result in player automatically being the Player that the SurfaceGui is in.

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