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

Can you get player by clicking surfacegui/button?

Asked by 9 years ago

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

1 answer

Log in to vote
0
Answered by 9 years ago

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.

Ad

Answer this question