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

How could I find the player who clicked a SurfaceGui?

Asked by 8 years ago

I am making a game, and there is a SurfaceGUI that everyone can see, and when a button is clicked, it brings up a picture. How can I see what player clicked the button? (So I can set permissions, I only want certain people to be able to click and have it actually do something)

I looked around, and saw something about it needing to be in PlayerGUI, which I'm not sure how that would work..

1 answer

Log in to vote
0
Answered by
DataStore 530 Moderation Voter
8 years ago

As you've already said yourself, and as the Wiki states, in order for you to check who clicked a button on a SurfaceGui, the SurfaceGui itself needs to be in the player's PlayerGui. By doing this, you can get the player by parenting up from the script inside the PlayerGui.

An alternative to this is to place a LocalScript in every player's PlayerGui (StarterGui) which connects the Button1Down event with the SurfaceGui's button in Workspace - This should work as required, though I'd still just go with the first option. You would, again, get the player by getting the LocalPlayer or parenting up to the player.

0
I'd have to edit for each player though right? (Wouldn't be hard, I just don't want to do it if I dont have to) And if the SurfaceGui is in the PlayerGui, how would it know what Part to be on? Tempestatem 884 — 8y
0
SurfaceGuis have an Adornee property. If you set this property to the part in Workspace that you want it to appear on, it will appear on that part. Changing the ' Face' property will dictate which side of the part the SurfaceGui is rendered on. And, what do you mean by you'd need to edit for each player? DataStore 530 — 8y
Ad

Answer this question